window.onload example 1: works as expected | WebReference

window.onload example 1: works as expected

window.onload example 1: works as expected

This example uses an external script specified with a script tag with src attribute to define an onload handler function init() that will be called when the page finishes loading. The onload handler is specified in the body tag as a onload attribute.

This example works as expected by displaying an alert box in both Netscape 6/Mozilla and Internet Explorer.