Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 255745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:57:23+00:00 2026-05-11T21:57:23+00:00

I have a page that on a certain action makes an iframe visible and

  • 0

I have a page that on a certain action makes an iframe visible and fills the iframe with some HTML (say for example a multi-select box and an ok button).

The OK button on the iframe has the onClick method defined kinda like this:

onClick="parent.hideIFrame();parent.processMultiSelectBox();"

When User clicks OK on the iframe (presumably after playing with the multi-select box), I’d like the iFrame to disappear immediately and then the selected values in the multi-select box can be processed. But this is not what’s happening. The iFrame remains visible during the time the other function runs and disappears only after the second function finishes.

The hideIFrame function is pretty straightforward:

function hideIFrame() {
  frmObj = document.all.iFrameID;
  if(frmObj) {
    frmObj.style.visibility = "hidden";
  }
}

I’ve paraphrased the above function for clarity (removed some indicator variable assignments etc.)

The second function actually loops on all the options in the multi-select object and does stuff with it. This takes about a half a second and only after that is done, does my iFrame disappear. It is a little bothersome to see it linger for half a second when I click ok.

My question is whether there is some way I can make the darn thing disappear faster. Speaking in “classical C” lingo, is there a “flush” for the change in visibility to happen immediately?

I did notice that if I put an “alert” as the first line in my second function, the iframe disappears immediately but now it is the OK on the alert box that lingers for the time it takes the second function to finish.

Thanks.

EDIT: Based on DDaviesBrackett’s answer, this is what I ended up doing:

The onclick in the iframe changed to:

onClick="parent.hideAndProcessMultiSelectBox(parm1, parm2);"

The hideAndProcessMultiSelectBox function was defined as:

function hideAndProcessMultiSelectBox( parm1, parm2 ) {
   hideIFrame();
   setTimeout( function() { processMultiSelectBox( parm1, parm2 ); }, 0 );
}

Voila.. no delay..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T21:57:23+00:00Added an answer on May 11, 2026 at 9:57 pm

    You’ve gotten to the root of your problem already; document reflow doesn’t happen until the current JS thread is done (so as not to repaint lots of times during JS execution). You need to return control to the browser before doing your expensive processing.

    The simplest way to achieve that, though it doesn’t make for obvious code in the slightest, is to call processMultiSelectBox in a setTimeout with a delay of 0:

    onClick="parent.hideIFrame();parent.setTimeout(parent.processMultiSelectBox,0);"
    

    If you need to pass parameters to the thing you’re setting a timeout on, you have two options: set a timeout on a string that evals to Javascript (bad, bad, very bad, horrible) or define an anonymous function that calls the one you’re interested in:

    onClick="parent.hideIFrame();parent.setTimeout(function(){parent.processMultiSelectBox(foo, bar, 'baz');},0);"
    

    RSolberg’s response may also help, though there’s a difference between visibility:hidden and display:none.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a certain page (we'll call it MyPage) that can be accessed from
I have a page that is generated which inserts an HTML comment near the
I have a page that has an iframe From one of the pages within
I'm writing a PHP application that manages some LDAP entries. I have one page
We have some code that occasionally flushed out certain keys in the ASP.NET cache
I have a page that uses $(id).show(highlight, {}, 2000); to highlight an element when
I have a page that is hitting a webservice every 5 seconds to update
I have a page that is supposed to launch the Print Preview page onload.
I have a Page that has a single instance of a UserControl that itself
I have a page that contains a user control that is just a personalized

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.