Window Interface

The Window interface provides properties and methods for accessing the windows and documents in the object model. A window object is an instance that implements the Window interface and represents the area where a Document is loaded into the browser. In a tabbed browser, each tab has its own window object; one window does not have access to the window object in any other browser tab. There is also one separate window object for each browser window and some methods, such as resizeTo and resizeBy, are delegated to one of these because they apply to a whole application window rather than a single browser tab.

Superinterfaces:
AbstractView
Implements:
EventTarget
Use:
window object
DOM PropertiesSupported
get onlyApplicationCache
window.applicationCache
get onlyboolean
window.closed
get or setDOMString
window.defaultStatus
window.defaultStatus = value
get onlyDOMObject
window.dialogArguments
get onlyDocument
window.document
get onlyElement
window.frameElement
get onlyWindowProxy
window.frames
get onlyHistory
window.history
get onlyint
window.innerHeight
get onlyint
window.innerWidth
get onlyunsigned long
window.length
get onlyStorage
window.localStorage
get onlyLocation
window.location
get onlyBarProp
window.locationbar
get or setDOMString
window.name
window.name = value
get onlyWindowProxy
window.opener
get onlyOpera
window.opera
addEventListener(DOMString type, any function, boolean capturePhase)
buildNumber()
buildNumber("inconspicuous")
clearErrorMessages()
collect()
initiate garbage collection
defineMagicFunction(DOMString functionName, function function)
defines a function for a method
defineMagicFunction(DOMString variableName, function getterFunction, function setterFunction)
defines functions for getting and setting a property
errorIndex()
errorMessage(int index)
getOverrideHistoryNavigationMode()
getPreference(DOMString section, DOMString preferenceName)
getPreferenceDefault(DOMString section, DOMString preferenceName)
isRegistered()
openInSourceViewer(DOMString url)
popXSLTransform()
postError(DOMString message, ...)
pushXSLTransform(Node xslStyleSheetNode)
setOverrideHistoryNavigationMode(DOMString mode)
setPreference(DOMString section, DOMString preferenceName, DOMString value)
SRPNumber()
version()
get onlyint
window.outerHeight
get onlyint
window.outerWidth
get onlyint
window.pageXOffset
get onlyint
window.pageYOffset
get onlyWindowProxy
window.parent
get onlyBarProp
window.personalbar
get or setany
window.returnValue
window.returnValue = value
A property of windows created with the showModalDialog method that can be used to set or get the value returned by the modal dialog window.
get onlyBarProp
window.scrollbars
get onlyWindowProxy
window.self
get onlyStorage
window.sessionStorage
get onlyDOMString
window.status
get onlyBarProp
window.statusbar
get onlyBarProp
window.toolbar
get onlyWindowProxy
window.top
get onlyWindowProxy
window.window
DOM Interface MethodsSupported
void
window.addEventListener(DOMString type, EventListener listener, boolean useCapture)
void
window.alert(DOMString message)
void
window.blur()
void
window.clearInterval(int intervalID)
void
window.clearTimeout(int timeoutID)
void
window.close()
boolean
window.confirm(DOMString message)
boolean
window.dispatchEvent(Event event)
void
window.focus()
CSSStyleDeclaration
window.getComputedStyle(Element element)
Selection
window.getSelection()
void
window.moveBy(int deltaX, int deltaY)
void
window.moveTo(int x, int y)
WindowProxy
window.open(DOMString url, DOMString target, DOMString features, DOMString replace)
void
window.postMessage(DOMString message, URI targetOrigin)
void
window.print()
DOMString
window.prompt(DOMString promptText, DOMString defaultValue)
void
window.removeEventListener(DOMString type, EventListener listener, boolean useCapture)
void
window.resizeBy(int deltaX, int deltaY)
void
window.resizeTo(int width, int height)
void
window.scroll(int x, int y)
void
window.scrollBy(int deltaX, int deltaY)
void
window.scrollTo(int x, int y)
int intervalID
window.setInterval(DOMString code, int delayInMilliseconds)
int timeoutID
window.setTimeout(DOMString code, int delayInMilliseconds)
any
window.showModalDialog(DOMString url, any argument)
void
window.stop()
DOM Events
Event TypePropertySupported
abortFunctiononabort
afterprintFunctiononafterprint
beforeprintFunctiononbeforeprint
beforeunloadFunctiononbeforeunload
blurFunctiononblur
canplayFunctiononcanplay
canplaythroughFunctiononcanplaythrough
changeFunctiononchange
clickFunctiononclick
contextmenuFunctiononcontextmenu
cuechangeFunctiononcuechange
dblclickFunctionondblclick
dragFunctionondrag
dragendFunctionondragend
dragenterFunctionondragenter
dragleaveFunctionondragleave
dragoverFunctionondragover
dragstartFunctionondragstart
dropFunctionondrop
durationchangeFunctionondurationchange
emptiedFunctiononemptied
endedFunctiononended
errorFunctiononerror
focusFunctiononfocus
formchangeFunctiononformchange
forminputFunctiononforminput
hashchangeFunctiononhashchange
inputFunctiononinput
invalidFunctiononinvalid
keydownFunctiononkeydown
keypressFunctiononkeypress
keyupFunctiononkeyup
loadFunctiononload
loadeddataFunctiononloadeddata
loadedmetadataFunctiononloadedmetadata
loadstartFunctiononloadstart
messageFunctiononmessage
mousedownFunctiononmousedown
mousemoveFunctiononmousemove
mouseoutFunctiononmouseout
mouseoverFunctiononmouseover
mouseupFunctiononmouseup
mousewheelFunctiononmousewheel
offlineFunctiononoffline
onlineFunctionononline
pauseFunctiononpause
playFunctiononplay
playingFunctiononplaying
pagehideFunctiononpagehide
pageshowFunctiononpageshow
popstateFunctiononpopstate
progressFunctiononprogress
ratechangeFunctiononratechange
readystatechangeFunctiononreadystatechange
redoFunctiononredo
resetFunctiononreset
resizeFunctiononresize
scrollFunctiononscroll
seekedFunctiononseeked
seekingFunctiononseeking
selectFunctiononselect
showFunctiononshow
stalledFunctiononstalled
storageFunctiononstorage
submitFunctiononsubmit
suspendFunctiononsuspend
timeupdateFunctionontimeupdate
undoFunctiononundo
unloadFunctiononunload
volumechangeFunctiononvolumechange
waitingFunctiononwaiting
Window onload Example
<script type="text/javascript">
window.addEventListener("load", function init() {
   alert('"Hello, World!" from Window load event');
}, false);
</script>
Event: