Wednesday, 28 December 2011

JavaScript Browser Window Object


Window Object

The window object represents an open window in a browser.
If a document contain frames (<frame> or <iframe> tags), the browser creates one window object for the HTML document, and one additional window object for each frame.
Note Note: There is no public standard that applies to the Window object, but all major browsers support it.

Window Object Properties

PropertyDescription
closedReturns a Boolean value indicating whether a window has been closed or not
defaultStatusSets or returns the default text in the statusbar of a window
documentReturns the Document object for the window (See Document object)
framesReturns an array of all the frames (including iframes) in the current window
historyReturns the History object for the window (See History object)
innerHeightSets or returns the inner height of a window's content area
innerWidthSets or returns the inner width of a window's content area
lengthReturns the number of frames (including iframes) in a window
locationReturns the Location object for the window (See Location object)
nameSets or returns the name of a window
navigatorReturns the Navigator object for the window (See Navigator object)
openerReturns a reference to the window that created the window
outerHeightSets or returns the outer height of a window, including toolbars/scrollbars
outerWidthSets or returns the outer width of a window, including toolbars/scrollbars
pageXOffsetReturns the pixels the current document has been scrolled (horizontally) from the upper left corner of the window
pageYOffsetReturns the pixels the current document has been scrolled (vertically) from the upper left corner of the window
parentReturns the parent window of the current window
screenReturns the Screen object for the window (See Screen object)
screenLeftReturns the x coordinate of the window relative to the screen
screenTopReturns the y coordinate of the window relative to the screen
screenXReturns the x coordinate of the window relative to the screen
screenYReturns the y coordinate of the window relative to the screen
selfReturns the current window
statusSets the text in the statusbar of a window
topReturns the topmost browser window

Window Object Methods

MethodDescription
alert()Displays an alert box with a message and an OK button
blur()Removes focus from the current window
clearInterval()Clears a timer set with setInterval()
clearTimeout()Clears a timer set with setTimeout()
close()Closes the current window
confirm()Displays a dialog box with a message and an OK and a Cancel button
createPopup()Creates a pop-up window
focus()Sets focus to the current window
moveBy()Moves a window relative to its current position
moveTo()Moves a window to the specified position
open()Opens a new browser window
print()Prints the content of the current window
prompt()Displays a dialog box that prompts the visitor for input
resizeBy()Resizes the window by the specified pixels
resizeTo()Resizes the window to the specified width and height
scroll() 
scrollBy()Scrolls the content by the specified number of pixels
scrollTo()Scrolls the content to the specified coordinates
setInterval()Calls a function or evaluates an expression at specified intervals (in milliseconds)
setTimeout()Calls a function or evaluates an expression after a specified number of milliseconds

No comments:

Post a Comment