JavaScript:Windows

Introduction
The window object is the top level object and contains all of the objects that build up a web page.

Window object

 * the window properties from JavaScript 1.1 can include the following:
 * toolbar, location, directories,status, menubar, scrollbars, resizable, copyhistory, width=[pixels], height=[pixels]

Example

You can also use window.print to provide a print button.

Windows (js8_01)
Open a new browser window

Example js8_01

Windows (js8_02)
Open a new browser window with specified properties

Note: I have used the \ to break the window properties string across several lines. You can put this all on one line.

Example js8_02

Windows (js8_03)
Example js8_03

Windows (js8_04) Controlling when to display a window
And now for a little example that looks at whether a check box is checked before allowing the window to be displayed. You could use this to only display a from once the data is validated (If the data validates ok set the check box). For a user you may like to make the check box hidden (but not while you are testing it!)

Example js8_04

Windows (js8_05) Including styles in a new Window
And now for a more sophisticated example to show you how to build an entire page with styles.

Example js8_05

Extensions
There are other interesting window object properties for you to explore

status
The status bar is the bar on the lower left side of the browser and is used to display temporary messages. The following example writes a message to the status bar


 * JavaScript Window Object (The Computer Technology Documentation Project, n.d.)