Saturday, February 5, 2011

Exactly when does an IFRAME onload event fire?

Does the IFRAME's onload event fire when the HTML has fully downloaded, or only when all dependent elements load as well? (css/js/img)

  • The latter: <body onload= fires only when all dependent elements (css/js/img) have been load as well.

    If you want to run JavaScript code when the HTML has been loaded, do this at the end of your HTML:

    <script>alert('HTML loaded.')</script></body></html>
    

    Here is a relevant e-mail thread about the difference between load and ready (jQuery supports both).

    From pts
  • Just when the html loads, not the dependent elements. (or so I think).

    To fire when the rest of the page loads do jQuery(window).load(function(){ or window.onload not document onready.

    You can also check to see if an image element is loaded and there... if image . load-- etc.

    From CodeJoust

0 comments:

Post a Comment