Window Object
The Window object represents the browser window. A Window object is created automatically with every instance of a <body> or <frame> tag.
IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).
Window Object Collections
Collection | Description | IE | F | N | W3C |
---|---|---|---|---|---|
frames[] | Returns all named frames in the window | 3 | 1 | 2 |
Window Object Objects
Object | Description | IE | F | N | W3C |
---|---|---|---|---|---|
clientInformation | Contains information about the browser | 4 | |||
clipboardData | 5 | ||||
document | This object can be used to access all elements in a page | 3 | |||
event | Represents the state of an event | 4 | |||
external | 4 | ||||
history | Contains the URLs the user has visited within a browser window | 3 | |||
location | Contains the current URL of the window | 3 | |||
navigator | Contains information about the client browser | 3 | |||
screen | Contains information about the client's display screen | 4 |
Window Object Properties
Property | Description | IE | F | N | W3C |
---|---|---|---|---|---|
closed | Returns a Boolean value that specifies whether the referenced window has been closed | 4 | 1 | 3 | |
defaultStatus | Sets or returns the default text in the statusbar of the windows (will be displayed when the page loads) | 3 | 1 | 2 | |
dialogArguments | Returns all variables passed into the modal dialog window | 4 | |||
dialogHeight | Sets or returns the height of the modal dialog window | 4 | |||
dialogLeft | Sets or returns the left coordinates of the modal dialog window | 4 | |||
dialogTop | Sets or returns the top coordinates of the modal dialog window | 4 | |||
dialogWidth | Sets or returns the width of the modal dialog window | 4 | |||
frameElement | Returns the frame/iframe object that is hosting the window in the parent document | 5 | |||
length | Sets or returns the number of frames in the window | 4 | 1 | 6 | |
name | Sets or returns the name of the window | 3 | 1 | 2 | |
offscreenBuffering | Sets or returns a Boolean value that specifies whether the window is drawn offscreen before being visible to the user | 4 | |||
opener | Sets or returns a reference to the window that created the window | 4 | 1 | 3 | |
parent | Returns the parent window | 3 | 1 | 2 | |
returnValue | Sets or returns the value returned from the modal dialog window | 4 | |||
screenLeft | Returns the x-coordinate of the upper left corner of the browser - relative to the upper left corner of the screen | 5 | |||
screenTop | Returns the y-coordinate of the top corner of the browser - relative to the top corner of the screen | 5 | |||
self | Returns a reference to the current window | 3 | 1 | 2 | |
status | Sets or returns the text in the statusbar of the window | 3 | 1 | 2 | |
top | Returns the topmost ancestor window | 3 | 1 | 2 |
Window Object Methods
Method | Description | IE | F | N | W3C | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
alert() | Displays an alert box with a specified message and an OK button | 3 | 1 | 2 | |||||||||||||||||||||||||
attachEvent("event",pointer) | 5 | ||||||||||||||||||||||||||||
blur() | Removes focus from the current window | 4 | 1 | 3 | |||||||||||||||||||||||||
clearInterval(ID) | Cancels a timeout that is set with the setInterval() method | 4 | 1 | 4 | |||||||||||||||||||||||||
clearTimeout(ID) | Cancels a timeout that is set with the setTimeout() method | 3 | 1 | 2 | |||||||||||||||||||||||||
close() | Closes the current window | 3 | 1 | 2 | |||||||||||||||||||||||||
confirm() | Displays a dialog box with a specified message and an OK and a Cancel button | 3 | 1 | 2 | |||||||||||||||||||||||||
createPopup() | Creates a pop-up window | 5 | |||||||||||||||||||||||||||
execScript("code", "lang") | Executes a specified script. The arguments can take the following values:
| 4 | |||||||||||||||||||||||||||
focus() | Sets focus on the current window | 4 | 1 | 3 | |||||||||||||||||||||||||
moveBy(x,y) | Moves the window a specified number of pixels in relation to its current co-ordinates | 4 | 1 | 4 | |||||||||||||||||||||||||
moveTo(x,y) | Moves the window's left and top edge to the specified co-ordinates | 4 | 1 | 4 | |||||||||||||||||||||||||
navigate("URL") | Loads the specified URL into the window | 3 | |||||||||||||||||||||||||||
open() | Opens a new browser window | 3 | |||||||||||||||||||||||||||
print() | Prints the contents of the current window | 5 | 1 | 4 | |||||||||||||||||||||||||
prompt() | Displays a dialog box that prompts the user for input | 3 | 1 | 2 | |||||||||||||||||||||||||
resizeBy() | Resizes the window by the specified pixels | 4 | |||||||||||||||||||||||||||
resizeTo() | Resizes the window to the specified width and height | 4 | 1.5 | ||||||||||||||||||||||||||
scroll() | Deprecated. Use scrollTo() instead | 4 | |||||||||||||||||||||||||||
scrollBy() | Scrolls the content by the specified number of pixels | 4 | 1 | 4 | |||||||||||||||||||||||||
scrollTo() | Scrolls the content to the specified coordinates | 4 | 1 | 4 | |||||||||||||||||||||||||
setActive() | 5 | ||||||||||||||||||||||||||||
setInterval(code, millisec[, "lang"]) | Calls a function / evaluate an expression every time a specified interval (in milliseconds) has been reached. The arguments can take the following values:
| 4 | 1 | 4 | |||||||||||||||||||||||||
setTimeout() | Calls a function or evaluates an expression after a specified number of milliseconds | 3 | 1 | 2 | |||||||||||||||||||||||||
showHelp("URL"[, contextID]) | Displays a Help file (must be of type .htm or .chm). When using this method, a second Help box appears when pressing F1 or when clicking Help on the menu bar. To prevent the default Help box from appearing set returnValue to false. The arguments can take the following values:
| 4 | |||||||||||||||||||||||||||
showModalDialog("URL"[, args, "list"]) | Loads a URL in a modal dialog box. A modal dialog box retains focus while open. The user CANNOT switch windows until the dialog box is closed. The arguments can take the following values: "URL" - Required. The URL of the document to display. args - Optional. The arguments to use when displaying the URL. Use this parameter to pass a value of any type, including an array of values. The dialog box can extract the values from the dialogArguments property of the window object. "list" - Optional. Specifies the window ornaments for the dialog box, using one or more of the following semicolon-delimited values:
| 4 | |||||||||||||||||||||||||||
showModelessDialog("URL"[, args, "list"]) | Loads a URL in a modeless dialog box. The modeless dialog box displays even when the user switches focus to another window (useful for menus and Help systems). The arguments can take the following values: "URL" - Required. The URL of the document to display. args - Optional. The arguments to use when displaying the URL. Use this parameter to pass a value of any type, including an array of values. The dialog box can extract the values from the dialogArguments property of the window object. "list" - Optional. Specifies the window ornaments for the dialog box, using one or more of the following semicolon-delimited values:
| 5 |
* The default unit of measure for dialogHeight and dialogWidth in IE4 is em; in IE5 it is px. Other values to use: cm, mm, in, pt, pc, or ex. For consistent results, use px! Note: The min. dialogHeight you can specify is 100px.
Window Object Events
Syntax: window.event_name="someJavaScriptCode"
Event | Description | IE | F | N | W3C |
---|---|---|---|---|---|
onBlur | Executes some code when a Blur event occurs | 1 | 3 | ||
onError | Executes some code when an Error event occurs | 1 | 3 | ||
onFocus | Executes some code when a Focus event occurs | 1 | 3 | ||
onLoad | Executes some code when an Load event occurs | 1 | 2 | ||
onResize | Executes some code when a Resize event occurs | 1 | 4 | ||
onUnload | Executes some code when an Unload event occurs | 1 | 2 |