load and unload

Test page.

Events overview page.

The load and unload events fire when an asset loads, or the entire page unloads.

load
The load event works on the page, scripts, style sheets, images, and iframes.
unload
The unload event works only on the page.

Note that the load and unload events should also fire when you use the Back and Foward buttons to navigate.

For some silly reason FF7b on Windows refuse to load my test iframe. The Mac version works fine, though.

Test IE 5.5 IE 6 IE 7 IE8 IE9 IE10 pr2 FF 7.0 Win FF 6.1 Mac Saf 5.1 Win Saf 5.1 Mac Chrome 14 Win Chrome 13 Mac Opera 11.51 Win Opera 11.51 Mac
Page
load and unload
Yes Untestable Yes Yes Yes Incomplete

The load event fires when a page is fully loaded, including all of its assets. The unload event fires when a page starts to unload. This should always happen, regardless of navigation method.

  • Opera doesn’t fire the unload event when you navigate Back and Forward. It does when you click on a link.
Image
load
Yes Yes Yes Yes Yes

When an image file is loaded the load event should fire from the <img> node.

Script
load
No Yes Yes Yes Yes Yes

When a script file is loaded the load event should fire from the <img> node. Note, however, that this happens only the first time a script is loaded into a specific script node. The second and subsequent times do not trigger a load event, since the script node has a flag set that prevents anything from happening.

CSS
load
Not tested Yes No No No Yes

When a CSS file is loaded the load event should fire from the <link> node.

iframe
load
Not tested No Yes Untestable Yes Yes Yes Yes

When an HTML page is loaded into an iframe the load event should fire from the <iframe> node.

Test IE 5.5 IE 6 IE 7 IE8 IE9 IE10 pr2 FF 7.0 Win FF 6.1 Mac Saf 5.1 Win Saf 5.1 Mac Chrome 14 Win Chrome 13 Mac Opera 11.51 Win Opera 11.51 Mac

No browser fires an error event when a style sheet resource isn’t found.