This example demonstrates how to call an object's methods in JavaScript.

In this example, the onLoad event handler calls the alert() method of the window object automatically, as soon as you open this page.

When you load another Web page or close your browser, the document's onUnload event handler calls the alert method.