View Full Version : Showmodaldialog and onreadystatechange in InernetExplorer 7

11-13-2006, 09:55 AM
In the application , i want to load the script in a frame, and while the script gets loaded i display a modaldialog.

To do this, I attach the event "onreadystatechange" to the frame in the method "ProcessPage". The handler for this event is "LoadScript" method which sets the boolean var bScriptLoaded to true when the script is loaded.

I call method ProcessPage through showModalDialog. The dialog should close when the var bScriptLoaded is set to true.

The problem is that the Modaldialog window does not close as "bSciptLoaded" does not get true.Its because the event does not get fired.
When I manually close the modaldialog, the event onreadystatechange gets fired and then the LoadScript is called.

So why does the event "onreadystatechange" does not get fired when modaldialog is opened in InternetExplorer7? This works fine in IE 6.

code is as follows:
function ProcessPage
tpageElement.attachEvent("onreadystatechange", loadManager = function()

function LoadScript
//Loads the script and sets bScriptLoaded = true.

function mymainmethod

args.fn(); //Executes ProcessPage method.
Loop = window.setInterval("Check()",1);

function Check()
if(args.bScriptLoaded == true)//Checks for the boolean var
window.returnValue = true;

11-13-2006, 01:39 PM
Are you sure this worked under IE6 with the latest patches?

From what I remember of this issue, as soon as you show a modal dialog window, the message pump for all other windows goes on "pause", this is why your onreadystate (from an object not in the modal window) never gets set to true.

The only solution I could offer would be to have some AJAX executing *IN* your modal window that brings down the document and either executes a callback or just closes itself when the doc has loaded, passing back a returnValue of the HTML which could then be written into an IFRAME of the parent page.

Much better to do away with the modal dialog entirey - just flash up a Div popup (optionally with a div behind it to "hide" the entire page", making it "kinda" modal) instead.

As a general rule I would say that programming around pop-up windows in the browser is not a good idea as you will always hit problems like this, and pop-up blockers and the fact that the ie popup blocker will get you if you try to open any window from any thread other than the main message pump (ie from an ajax callback).

11-28-2006, 09:46 AM
The code works fine in IE6. The readystate changes and the modal dialog closes when the readystate gets set to 'complete'. I dont know whts the problem with IE7.Any idea?

Probably the work around you have suggested could work.
but it would really be helpful if i find alternate to this scenario.
I tried making an ajax call but the problem there is i am not able to access the variable of the js file loaded in the aspx page. I wonder why this happens. any clue? It would really be helpful.