Loading ...
Sorry, an error occurred while loading the content.
 

RE: [ydn-javascript] Modal "loading..." dialog in IE form: problem & solution

Expand Messages
  • Bart King
    Hello, Just thought I d add a comment into what these strange Operation aborted errors that IE6 (and IE7 it seems) pop up occasionally mean. It seems to
    Message 1 of 2 , Sep 27, 2006
      Hello,

      Just thought I'd add a comment into what these strange "Operation
      aborted" errors that IE6 (and IE7 it seems) pop up occasionally mean.

      It seems to relate to general race conditions that can occur inside the
      rendering engine of IE. Such a race condition can be where some inline
      JavaScript (that is, JavaScript code that is not in a separate .js file)
      gets called _before_ the actual document has been constructed in the
      rendering engine's layout. Like, calling getElementById() on a valid
      element, but too early.

      I have also seen it occur purely down to whitespace inside inline script
      - extremely strange!

      Nonetheless, it's a tricky, seemingly hit-and-miss error, but
      fortunately, it's rather rare. I find not using inline script in a
      document is the way to go to never see the error in the first place
      (since scripts are then executed before the document body is parsed).
      It also forces developers to create a listener event under onload, which
      is the "correct" way to ensure nothing nasty happens.

      But, if inline script is to be insisted upon, there is a potential (but
      not perfect) saving grace in that of the defer attribute on <script>.
      So you can do:

      <script type="text/javascript" defer="true">
      alert("I won't get called until page has finished
      loading!");
      </script>

      What "finished loading" actually is, though, seems to be undefined - is
      it when the HTTP socket has recv()'d all the data or is it when the HTML
      has been fully parsed? Hence, not a perfect solution.

      More here:
      http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/def
      er.asp

      Cheers,
      --
      Bart King
      http://www.bart666.com -- +44 781 219 5654

      -----Original Message-----
      From: ydn-javascript@yahoogroups.com
      [mailto:ydn-javascript@yahoogroups.com] On Behalf Of Mike Bridge
      Sent: 27 September 2006 18:47
      To: ydn-javascript@yahoogroups.com
      Subject: [ydn-javascript] Modal "loading..." dialog in IE form: problem
      & solution

      Hi-

      I have a modal "loading..." YUI panel which pops up during the first
      access to a page. This worked ok in Firefox, but IE6 gave me an "alert"
      error window which says "Internet Explorer cannot open the Internet site
      ... Operation aborted."

      I eventually figured out that the problem was that the dialog's "show()"
      method was being called from inside the FORM tag. Once I moved it so
      that it was inside the BODY tag but outside the FORM tag, it worked
      fine.

      I'm posting this in case someone else encounters this problem in the
      future, but I'd also like to if anyone knows why this occurs. I hate
      fixing something without knowing why it works. :(

      This is the (simplified) code I'm using:

      <script type="text/javascript">
      var win=new YAHOO.widget.Panel("wait",
      {
      width:"240px",
      fixedcenter:true,
      underlay:"shadow",
      close:false,
      draggable:false,
      modal:true
      });
      win.setHeader("Loading...");
      win.setBody("...testing...");

      win.render(document.body);
      win.show();
      YAHOO.util.Event.addListener(window, "load", function()
      {win.hide()});

      </script>

      Thanks,

      -Mike







      Yahoo! Groups Links
    Your message has been successfully submitted and would be delivered to recipients shortly.