JavaScript (JS) interacts with the window using objects, properties, and methods. This allows us to communicate with the web user and alert them, confirm information, and prompt the user for information.
The window OBJECTS include: document, form, img, button, and many others objects. Objects have properties.
The web page is a document (is the Object) write (is the Method). This example will write -Welcome to JavaScript 101
The window PROPERTIES include: document, bgcolor, fgcolor, default status, lastmodified, history, location, name, and many others
In this example you will see the message: -This page was last modified: and the date it was last modified. The JS code lastModified is a predefined object property the browser can retreive.
In this example you will see the Name and Version of your browser. The name and version of the browser are examples of the browser properties
The window METHODS include: alert, prompt, confirm, write, close, open, setTimeout, reload, clearTimeout, blur, focus and many others
Alert Method displays a dialogue box with a message this one says -JavaScript is Interactive. Use Alerts to commounicate a message to the user.
Confirm Method is used to give the web user a choice. In this example the Confirm asks -Go to the new page now? or the user can cancel to stay on the current page.
This Prompt Method will ask the user to enter the secret passwords. This is not a secret password because the answer is in the JS located in the head of the document! It can be useful but is not secure.
Event Handlers are used to create on click events that happen when the mouse is used to rollover and click on things like text, buttons, and images.
In this example there is a rollover image triggered with JS onMouse over event handler: