[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

11/06/2009 at 08:18AM PST, ID: 24878333 | Points: 500
[x]
Attachment Details

onDomReady problem with IE

Asked by fvo_afb in JavaScript, Internet Explorer Web Browser, Document Object Model

Tags: Internet Explorer, DOM Ready

onDomReady problem with IE

In our webapplication we're using an overlaying Div to prevent users from sending a submit before site is loaded completely.
To do this we use the DOMContentLoaded-event of webbrowser. When DOM is completed the Div should disappear and user can start working.
Everything works fine in Firefox. Because IE doesn't support the DOMContentLoaded-event we use the defer-attribute for a script, which is loaded at the end of page.

Following sourcecode is used:

domready.js:

   window.onDomReady = DomReady;

   //Setup the event
   function DomReady(fn)
   {
      //W3C
      if(document.addEventListener)
      {
         document.addEventListener("DOMContentLoaded", fn, false);
      }
      //IE
      else
      {
         if(document.all)
         {
            document.write('<script type="text/javascript" defer="defer" src="ie_onload.js"><\/script>');
         }
         var oldLoad = window.onload;
         var newLoad = oldLoad ? function(){fn.call(this);oldLoad.call(this);} : fn;
         window.onload = newLoad;
                               }
         }

ie_onload.js:

         hideModalDialog();
               
In page-source the domready.js is loaded in header. In body following code shows up the overlaying Div and setups the defined onDomReady-attribut to hide the Div:

   <script type="text/javascript">
         showModalDialog();
         window.onDomReady(function(){hideModalDialog();});
    </script>
               
Now the problem: In 100% of loading pages in Firefox the page is loaded correctly and the Div disappears after loading. The same works fine in IE, but in 0,01% of all loadings the Div
never disappears and user can't interact. The statusbar shows "Done" for page. When reloading the page the site is loaded correctly. We use a template system and the code for showing and hiding the Div is included everywhere. But the problem can't be located to a single page it appears randomly and is very hard to reproduce.
Newest investigations show the problem appears more often when loading sites in low-bandwiths e.g. UMTS.

In former versions of our DomReady-function we used the .onreadystatechange instead of defer-attribute but the loading-problems had appeared more often.
We need a solution for all versions of IE >=Version 6.
 
Keywords: onDomReady problem with IE
 
Loading Advertisement...
 
[+][-]11/06/09 10:00 AM, ID: 25761379

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/09/09 06:59 AM, ID: 25776421

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/09/09 11:53 AM, ID: 25779328

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/10/09 06:01 AM, ID: 25785373

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy / EE_QW_3_20080625