Javascript Sample 4: executing Javascript when the page is loaded

You can execute Javascript code whenever the page loads into the browser. View source, and take a look at the stuff in the <head> section as well as the <body> tag.