Exactly when does an IFRAME onload event fire?

Robin Rodricks picture Robin Rodricks · May 2, 2009 · Viewed 27.8k times · Source

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)

Answer

pts picture pts · May 2, 2009

The latter: <body onload= fires only when all dependent elements (css/js/img) have been loaded 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).