JavaScript Reference :: Window

A Window object is automatically created by a browser window. Using the keyword "window" will reference the current window. If you would like to reference another window directly, you can use the open method to return a reference to the new window.

methods

void alert(string message)
Displays a message to the user.
string atob(string toEncode)
Returns the string to encode as Base-64.
void back(int numberOfDocuments)
Moves backward through the window history stack the specified number of documents.
void blur()
Removes focus from the window.
string btoa(string base64String)
Returns a decoded string that had been encode in Base-64.
void captureEvents(event eventToCapture)
Captures all the events of the specified type.
void clearInterval(IntervalId intervalId)
Clears the interval referenced by the intervalId.
void clearTimeout(TimeoutId timeoutId)
Clears the timeout event created by setTimeout.
void close()
Closes the window.
int confirm(string message)
Presents a message box to the user and returns the index of the button clicked.
void disableExternalCapture()
Disables the capturing of events previously enabled using enableExternalCapture.
void enableExternalCapture()
Enables frames to capture events in documents loaded into frames from different servers.
string find([string stringToFind[, boolean caseSensitive[, boolean searchBackward]]])
Searches the document for a string. If the string to find is not specified, a dialog box is opened that allows the user to specify the string to find as well as the boolean to indicate case-sensitivity and the boolean to indicate that the search should be backward.
void focus()
Sets focus on the window object.
void forward(int numberOfDocuments)
Moves forward through the window history stack the specified number of documents.
void handleEvent(string eventType)
Calls the handler for the specified event.
void home()
Loads the document specified as the home document.
void moveBy(int horizontal, int vertical)
Scrolls the window contents by the specified number of pixels.
void moveTo(int horizontal, int vertical)
Scrolls to the specified position.
Window open(string url[, string windowName[, string options]])
Opens a new window with the specified options. If the window is named, it can be referenced as a target. Options that can be specified are:
height
Height of the window.
scrollbars
Whether or not scrollbars are shown when content overflows the height and/or width.
statusbar
Whether or not the status bar is shown.
toolbar
Whether or not the toolbar is shown.
width
Width of the window.
void print()
Opens the print dialog box to print the current document.
string prompt(string message)
Displays the specified message and returns the user input.
void releaseEvents(string eventType)
Releases the event of the specified type and sends them to objects further down in the event hierarchy.
void resizeBy(int horizontal, int vertical)
Resizes the window by the specified number of pixels.
void resizeTo(int horizontal, int vertical)
Resizes the window to the specified number of pixels.
void routeEvent(event eventType)
Sends a captured event down the event heirarchy to the original target or the object specified to capture the event.
void scrollBy(int horizontal, int vertical)
Scrolls the window contents by the specified number of pixels.
void scrollTo(int horizontal, int vertical)
Scrolls to the specified position.
void setHotKeys(boolean enabled)
Enables or disables hotkeys for windows that do not display a menu. In order to change this value you must have UniversalBrowserWrite priviledge enabled.
IntervalId setInterval(object handler, int milliseconds)
Sets a repeating timer at the specified number of milliseconds. When the timer expires, the handler, which may be either a string that contains valid JavaScript code or a JavaScript Function object, is called. This method returns an IntervalId that can be passed as a parameter to the clearInterval method.
void setResizable(boolean isResizable)
Sets whether or not the window can be resized by the user.
TimeoutId setTimeout(object handler, int milliseconds)
Creates a timeout event for the specified interval. When the timeout event occurs, the specified command is executed and the timer expires. Command can be a function object or a string containing a JavaScript statement. This method returns an TimeoutId that can be passed as a parameter to the clearTimeout method.
void setZOptions(string option)
Sets the z-index of the window. Valid values are listed below. In order to use this method, you must have UniversalBrowserWrite enabled.
  • "alwaysRaised"
  • "alwaysLowered"
  • "z-lock"
void stop()
Cancels the current download.
object toSource()
Returns a literal representing the source code of the object e.g "function Object() { [native code] }" or "function Car(manufactuer, model, productionyear) { this.make = manufactuer; this.model = model; this.year = productionyear; }".
string toString()
Returns a string representing the object i.e. "[object Object]".
void unwatch(property)
Removes a previously set watchpoint.
								
object valueOf()
Returns the primitive value of the object e.g. "function Object() { [native code] }".
void watch(property, handlingFunction)
Calls the handlingFunction when the property is changed.
								

properties

closed
Whether or not a window has been closed.
constructor
The constructor method is the base method used to create an instance of the object.
crypto
A reference to the crypto object in the window. The crypto object has two methods: random (which returns a random number) and signText (which creates a signed hash). It is advisable that neither of these be referenced in client-side JavaScript due to the lack of widespread support.
defaultStatus
The default text in the status bar.
document
The Document object in the window.
frames
An array of Frame objects in the window.
history
The History object in the window.
innerHeight
The inner height of the window, i.e. the display area.
innerWidth
The inner width of the window, i.e. the display area.
left
The location, in pixels, of the left border of the window object in the user's display.
location
The Location of the document in the window.
locationbar
Whether or not the location bar (also known as the address bar) is displayed.
menubar
Whether or not the menu bar is displayed.
name
The name of the window. In order to access this property, the window must have been named when opened.
offscreenBuffering
opener
The window object that opened the window.
outerHeight
The height of the outer border in pixels.
outerWidth
The width of the outer border in pixels.
parent
The window containing the window object.
personalbar
The personal bar (or directories bar). This object has one property, visible, that is boolean.
window.personalbar.visible = false;
								
prototype
Exposes the prototype for the method or property of the object.
scrollbars
The scrollbars in the window. This object has one property, visible, that is boolean.
window.scrollbars.visible = false;
								
self
A synonym for the current window object.
status
The string displayed in the status bar. Not all browsers allow this to be changed.
statusbar
The statusbar in the window. This object has one property, visible, that is boolean.
window.statusbar.visible = false;
								
toolbar
The toolbar in the window. This object has one property, visible, that is boolean.
window.scrollbars.visible = false;
								
top
The location, in pixels, of the top border of the window object in the user's display.
window
A synonym for the current window object.

events

onblur
onerror
onfocus
onload
onmousemove
onresize
onunload