window.onload example 5 | WebReference

window.onload example 5

window.onload example 5

This example uses an external script specified by writing out a script tag with src via document.write in the body tag. The assignment to window.onload occurs in the dynamically loaded script.

Note that the assignment to window.onload = init; occurs inside of the script block where the script tag is written out.