Description: Bind an event handler to the "load" JavaScript event.
.load( handler(eventObject) )
.load( [ eventData ], handler(eventObject) )
This method is a shortcut for .bind('load', handler).
The load event is sent to an element when it and all sub-elements have been completely loaded. This event can be sent to any element associated with a URL: images, scripts, frames, iframes, and the window object.
It is possible that the load event will not be triggered if the image is loaded from the browser cache. To account for this possibility, we can use a special load event that fires immediately if the image is ready.
event.special.loadis currently available as a plugin.
For example, consider a page with a simple image:
<img src="book.png" alt="Book" id="book" />
The event handler can be bound to the image:
$('#book').load(function() {
// Handler for .load() called.
});
As soon as the image has been loaded, the handler is called.
In general, it is not necessary to wait for all images to be fully loaded. If code can be executed earlier, it is usually best to place it in a handler sent to the .ready() method.
The Ajax module also has a method named
.load(). Which one is fired depends on the set of arguments passed.
Examples
Example 1
Run a function when the page is fully loaded including graphics.$(window).load(function () { // run code });

