Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Showmodaldialog and onreadystatechange in InernetExplorer 7

    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()
    {if(tpageElement.readyState=='complete'){LoadScript();}}

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

    function mymainmethod
    {
    ...
    showModalDialog("process.htm",args,param1);
    ....
    }

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



    function Check()
    {
    if(args.bScriptLoaded == true)//Checks for the boolean var
    {
    window.clearInterval(Loop);
    window.returnValue = true;
    window.close();
    }
    }

  • #2
    VR2
    VR2 is offline
    New Coder
    Join Date
    Jul 2006
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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).

  • #3
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

    Thanks...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •