Home | Top | Website design | JavaScript Editor JavaScript EditorGet Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.


window Object

Represents an open window in the browser.

Members Table

The following table lists the members exposed by the window object. Click a tab on the left to choose the type of member you want to view.

Attributes/Properties  
 
Attributes/Properties
Collections
Events
Methods
Objects
Property Description
closed Retrieves whether the referenced window is closed.
defaultStatus Sets or retrieves the default message displayed in the status bar at the bottom of the window.
dialogArguments Retrieves the variable or array of variables passed into the modal dialog window.
dialogHeight Sets or retrieves the height of the modal dialog window.
dialogLeft Sets or retrieves the left coordinate of the modal dialog window.
dialogTop Sets or retrieves the top coordinate of the modal dialog window.
dialogWidth Sets or retrieves the width of the modal dialog window.
frameElement Retrieves the frame or iframe object that is hosting the window in the parent document .
length Sets or retrieves the number of objects in a collection.
name Sets or retrieves a value that indicates the window name.
offscreenBuffering Sets or retrieves whether objects are drawn offscreen before being made visible to the user.
opener Sets or retrieves a reference to the window that created the current window.
parent Retrieves the parent of the window in the object hierarchy.
returnValue Sets or retrieves the value returned from the modal dialog window.
screenLeft Retrieves the x-coordinate of the upper left-hand corner of the browser's client area, relative to the upper left-hand corner of the screen.
screenTop Retrieves the y-coordinate of the top corner of the browser's client area, relative to the top corner of the screen.
self Retrieves a reference to the current window or frame.
status Sets or retrieves the message in the status bar at the bottom of the window.
top Retrieves the topmost ancestor window.

Remarks

You can use the window object to retrieve information about the state of the window. You also can use this object to gain access to the document in the window, to the events that occur in the window, and to features of the browser that affect the window.

Typically, the browser creates one window object when it opens an HTML document. However, if a document defines one or more frames (that is, contains one or more frame or iframe tags), the browser creates one window object for the original document and one additional window object for each frame. These additional objects are child windows of the original window and can be affected by actions that occur in the original. For example, closing the original window causes all child windows to close. You can also create new windows (and corresponding window objects) using methods such as open , showModalDialog , and showModelessDialog .

You can apply any window property, method, or collection to any variable or expression that evaluates to a window object, regardless of how that window was created. Additionally, you can access all window properties, methods, and collections in the current window by using the property, method, or collection name directly—that is, without prefixing it with an expression that evaluates to the current window object. However, to help make more readable code and to avoid potential ambiguities, many authors use the window keyword when accessing window properties, methods, and collections for the current window. This keyword always refers to the current window.

Note   : The window's properties, methods, and collection names are reserved keywords and cannot be used as the names of variables or routines.

The following table lists pertinent information for some of the properties of the window object.

Property Method Description
opener open The opener property is available only from a page opened using the window . open method.
parent , top None The parent and top properties are available for a window opened inside a frame or iframe . The two properties return the topmost parent and immediate parent, respectively.
parent , top open The parent and top properties are available for a window opened via the open method or as a dialog and returns the current window.
length None Regardless of how the window is opened, the length property returns the number of frames in a window.
dialogArguments , dialogHeight , dialogLeft , dialogTop , dialogWidth , returnValue showModalDialog and showModelessDialog These properties are available only for windows created using the two methods listed— showModalDialog and showModelessDialog

This object is available in script as of Internet Explorer 3.0.

Examples

This example displays an alert for the current window.

alert("A simple message.")

This example checks whether the current window contains child windows and, if it does, displays the names of those child windows.

if ( window .frames != null )
{ for ( i = 0; i< window .frames.length; i++ )
window .alert ("Child window " +i+ " is named "+ window .frames(i).name); }

This example shows a simple event handler function for the window's onload event. In the absence of a "window" element, the body element hosts the following window object events: onblur , onbeforeunload , onfocus , onload , and onunload .

<BODY onload=" window.status='Page is loaded!'">

 

Home | Top | Website design | JavaScript Editor JavaScript EditorGet Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.