window
对象表示一个包含DOM文档的窗口,其 document
属性指向窗口中载入的 DOM文档 。使用 document.defaultView
属性可以获取指定文档所在窗口。
本节为 DOM window
对象中可用的所有方法、属性和事件提供简要参考。window
对象实现了 Window
接口,此接口继承自 AbstractView
接口。一些额外的全局函数、命名空间、对象、接口和构造函数与 window 没有典型的关联,但却是有效的,它们在 JavaScript参考 和 DOM参考 中列出。
在标签浏览器(比如Firefox)中,每个标签具有自己的 window
对象(如果你在开发扩展,浏览器窗口也是一个独立的 window ,详情参见 Working with windows in chrome code)。也就是说,同一个窗口的标签之间不会共享一个 window
对象。有一些方法,如 window.resizeTo
和 window.resizeBy
之类的方法会作用于整个窗口而不是 window
对象所属的那个标签。一般而言,如果无法恰当地作用于标签,则会将其作用于窗口。
属性
-
这个接口从
EventTarget
接口继承属性,通过WindowTimers
、WindowBase64
和WindowEventHandlers
实现属性。注意,对象类型的属性(例如:覆盖内建元素的原型)列表于以下单独的小节中。
OfflineResourceList
对象提供对窗口的离线资源的访问。Window.closed
只读- 这个属性指示当前窗口是否关闭。
Window.Components
- 此入口指向一些 XPCOM 特性。有些属性(例如 classes )仅可用于较高特权的代码。Web代码不应该使用此属性。
Window.console
只读- 返回console对象的引用,该对象提供了对浏览器调试控制台的访问。
Window.content
and Window._content 只读- 返回当前window的content元素的引用。通过带下划线的过时变种方法不再可以获得 Web content。
Window.controllers
只读- 返回当前chrome window的XUL控制器对象。
Window.crypto
只读- 返回浏览器crypto对象。
Window.defaultStatus
已废弃 Gecko 23- 获取或设置指定窗口的状态栏文本。
Window.devicePixelRatio
只读- 返回当前显示器的物理像素和设备独立像素的比例。
Window.dialogArguments
只读- 获取在调用
window.showModalDialog()
时传递给窗口的参数(如果它是一个对话框)。这是一个nsIArray
。 Window.directories
window.personalbar
的另一种形式。Window.document
只读- 返回对当前窗口所包含文档的引用。
Window.frameElement
只读- 返回嵌入窗口的元素,如果未嵌入窗口,则返回null。
Window.frames
只读- 返回当前窗口中所有子窗体的数组。
Window.fullScreen
- 此属性表示窗口是否以全屏显示。
已废弃 Gecko 13window.globalStorage
- Unsupported since Gecko 13 (Firefox 13). Use
Window.localStorage
instead.
Was: Multiple storage objects that are used for storing data across multiple pages. Window.history
只读- 返回history对象的引用.
Window.innerHeight
- 获得浏览器窗口的内容区域的高度,包含水平滚动条(如果有的话).
window.innerWidth
- 获得浏览器窗口的内容区域的宽度,包含垂直滚动条(如果有的话).
Window.length
只读- Returns the number of frames in the window. See also
window.frames
. Window.location
只读- 获取、设置window对象的location, 或者当前的 URL.
Window.locationbar
只读- Returns the locationbar object, whose visibility can be toggled in the window.
Window.localStorage
只读- Returns a reference to the local storage object used to store data that may only be accessed by the origin that created it.
Window.menubar
只读- Returns the menubar object, whose visibility can be toggled in the window.
Window.messageManager
- Returns the message manager object for this window.
Window.mozAnimationStartTime
只读- The time in milliseconds since epoch at which the current animation cycle began.
Window.mozInnerScreenX
只读- Returns the horizontal (X) coordinate of the top-left corner of the window's viewport, in screen coordinates. This value is reported in CSS pixels. See
mozScreenPixelsPerCSSPixel
innsIDOMWindowUtils
for a conversion factor to adapt to screen pixels if needed. Window.mozInnerScreenY
只读- Returns the vertical (Y) coordinate of the top-left corner of the window's viewport, in screen coordinates. This value is reported in CSS pixels. See
mozScreenPixelsPerCSSPixel
for a conversion factor to adapt to screen pixels if needed. Window.mozPaintCount
只读- Returns the number of times the current document has been rendered to the screen in this window. This can be used to compute rendering performance.
Window.name
- Gets/sets the name of the window.
Window.navigator
只读- Returns a reference to the navigator object.
Window.opener
- Returns a reference to the window that opened this current window.
Window.outerHeight
只读- Gets the height of the outside of the browser window.
Window.outerWidth
只读- Gets the width of the outside of the browser window.
Window.pageXOffset
只读- An alias for
window.scrollX
. Window.pageYOffset
只读- An alias for
window.scrollY
Window.sessionStorage
只读- Returns a reference to the session storage object used to store data that may only be accessed by the origin that created it.
SpeechSynthesisGetter.speechSynthesis
只读Window.parent
只读- Returns a reference to the parent of the current window or subframe.
Window.performance
只读- Provides a hosting area for performance related attributes.
Window.personalbar
只读- Returns the personalbar object, whose visibility can be toggled in the window.
Window.pkcs11
已废弃 Gecko 29- Formerly provided access to install and remove PKCS11 modules.
Window.returnValue
- The return value to be returned to the function that called
window.showModalDialog()
to display the window as a modal dialog. Window.screen
只读- Returns a reference to the screen object associated with the window.
Window.screenX
只读- Returns the horizontal distance of the left border of the user's browser from the left side of the screen.
Window.screenY
只读- Returns the vertical distance of the top border of the user's browser from the top side of the screen.
Window.scrollbars
只读- Returns the scrollbars object, whose visibility can be toggled in the window.
Window.scrollMaxX
只读- The maximum offset that the window can be scrolled to horizontally, that is the document width minus the viewport width.
Window.scrollMaxY
只读- The maximum offset that the window can be scrolled to vertically (i.e., the document height minus the viewport height).
Window.scrollX
只读- Returns the number of pixels that the document has already been scrolled horizontally.
Window.scrollY
只读- Returns the number of pixels that the document has already been scrolled vertically.
Window.self
只读- Returns an object reference to the window object itself.
Window.sessionStorage
- Returns a storage object for storing data within a single page session.
Window.sidebar
只读- Returns a reference to the window object of the sidebar.
Window.status
- Gets/sets the text in the statusbar at the bottom of the browser.
Window.statusbar
只读- Returns the statusbar object, whose visibility can be toggled in the window.
Window.toolbar
只读- Returns the toolbar object, whose visibility can be toggled in the window.
Window.top
只读- Returns a reference to the topmost window in the window hierarchy. This property is read only.
Window.window
只读- Returns a reference to the current window.
window[0]
,window[1]
, etc.- Returns a reference to the
window
object in the frames. SeeWindow.frames
for more details. -
Methods
This interface inherits methods from the
EventTarget
interface and implements methods fromWindowTimers
,WindowBase64
, andWindowEventHandlers
. EventTarget.addEventListener()
- Register an event handler to a specific event type on the window.
Window.alert()
- Displays an alert dialog.
WindowBase64.atob()
- Decodes a string of data which has been encoded using base-64 encoding.
Window.back()
- Moves back one in the window history.
Window.blur()
- Sets focus away from the window.
WindowBase64.btoa()
- Creates a base-64 encoded ASCII string from a string of binary data.
Window.captureEvents()
- Registers the window to capture all events of the specified type.
Window.clearImmediate()
- Cancels the repeated execution set using
setImmediate
. WindowTimers.clearInterval()
- Cancels the repeated execution set using
WindowTimers.setInterval()
. WindowTimers.clearTimeout()
- Cancels the repeated execution set using
WindowTimers.setTimeout()
. Window.close()
- Closes the current window.
Window.confirm()
- Displays a dialog with a message that the user needs to respond to.
Window.disableExternalCapture()
已废弃 Gecko 24- FIXME: NeedsContents
Window.dispatchEvent()
- Used to trigger an event.
Window.dump()
- Writes a message to the console.
Window.enableExternalCapture()
已废弃 Gecko 24- FIXME: NeedsContents
Window.find()
- Searches for a given string in a window.
Window.focus()
- Sets focus on the current window.
Window.forward()
- Moves the window one document forward in the history.
Window.getAttention()
- Flashes the application icon.
Window.getAttentionWithCycleCount()
- FIXME: NeedsContents
Window.getComputedStyle()
- Gets computed style for the specified element. Computed style indicates the computed values of all CSS properties of the element.
Window.getDefaulComputedStyle()
- Gets default computed style for the specified element, ignoring author stylesheets.
Window.getSelection()
- Returns the selection object representing the selected item(s).
Window.home()
- Returns the browser to the home page.
Window.matchMedia()
- Returns a
MediaQueryList
object representing the specified media query string. Window.maximize()
- FIXME: NeedsContents
Window.minimize()
(top-level XUL windows only)- Minimizes the window.
Window.moveBy()
- Moves the current window by a specified amount.
Window.moveTo()
- Moves the window to the specified coordinates.
Window.mozRequestAnimationFrame()
- Tells the browser that an animation is in progress, requesting that the browser schedule a repaint of the window for the next animation frame. This will cause a
MozBeforePaint
event to fire before that repaint occurs. Window.open()
- Opens a new window.
Window.openDialog()
- Opens a new dialog window.
Window.postMessage()
- Provides a secure means for one window to send a string of data to another window, which need not be within the same domain as the first.
Window.print()
- Opens the Print Dialog to print the current document.
Window.prompt()
- Returns the text entered by the user in a prompt dialog.
Window.releaseEvents()
- Releases the window from trapping events of a specific type.
Window.removeEventListener()
- Removes an event listener from the window.
Window.resizeBy()
- Resizes the current window by a certain amount.
Window.resizeTo()
- Dynamically resizes window.
Window.restore()
- FIXME: NeedsContents
Window.routeEvent()
已废弃 Gecko 24- FIXME: NeedsContents
Window.scroll()
- Scrolls the window to a particular place in the document.
Window.scrollBy()
- Scrolls the document in the window by the given amount.
Window.scrollByLines()
- Scrolls the document by the given number of lines.
Window.scrollByPages()
- Scrolls the current document by the specified number of pages.
Window.scrollTo()
- Scrolls to a particular set of coordinates in the document.
Window.setCursor()
- Changes the cursor for the current window
Window.setImmediate()
- Executes a function after the browser has finished other heavy tasks
WindowTimers.setInterval()
- Schedules the execution of a function each X milliseconds.
Window.setResizable
- FIXME: NeedsContents
WindowTimers.setTimeout()
- Sets a delay for executing a function.
Window.showModalDialog()
- Displays a modal dialog.
Window.sizeToContent()
- Sizes the window according to its content.
Window.stop()
- This method stops window loading.
Window.updateCommands()
- Updates the state of commands of the current chrome window (UI).
事件处理函数
-
已批准的 English (US) 版本:
Window
- 属性
applicationCache
caches
closed
console
controllers
[我来译!]crypto
defaultStatus
[我来译!]devicePixelRatio
dialogArguments
directories
[我来译!]document
frameElement
frames
fullScreen
history
indexedDB
[我来译!]innerHeight
innerWidth
isSecureContext
[我来译!]isSecureContext
[我来译!]length
localStorage
location
locationbar
[我来译!]menubar
[我来译!]messageManager
mozAnimationStartTime
mozInnerScreenX
[我来译!]mozInnerScreenY
[我来译!]mozPaintCount
name
navigator
onabort
onafterprint
[我来译!]onanimationcancel
onanimationend
onanimationiteration
[我来译!]onappinstalled
[我来译!]onauxclick
[我来译!]onbeforeinstallprompt
onbeforeprint
onbeforeunload
onblur
onchange
onclick
onclose
oncontextmenu
ondblclick
ondevicelight
[我来译!]ondevicemotion
[我来译!]ondeviceorientation
[我来译!]ondeviceorientationabsolute
[我来译!]ondeviceproximity
[我来译!]ondragdrop
[我来译!]onerror
onfocus
ongamepadconnected
[我来译!]ongamepaddisconnected
[我来译!]ongotpointercapture
onhashchange
oninput
onkeydown
onkeypress
onkeyup
onlanguagechange
onload
onloadend
onloadstart
[我来译!]onlostpointercapture
[我来译!]onmousedown
onmousemove
onmouseout
onmouseover
onmouseup
onmozbeforepaint
[我来译!]onpaint
[我来译!]onpointercancel
[我来译!]onpointerdown
onpointerenter
[我来译!]onpointerleave
[我来译!]onpointermove
[我来译!]onpointerout
[我来译!]onpointerover
[我来译!]onpointerup
[我来译!]onpopstate
onrejectionhandled
[我来译!]onreset
onresize
onscroll
onselect
onselectionchange
[我来译!]onselectstart
[我来译!]onstorage
onsubmit
ontouchcancel
ontouchmove
ontouchstart
[我来译!]ontransitioncancel
[我来译!]ontransitionend
[我来译!]onunhandledrejection
[我来译!]onunload
onuserproximity
[我来译!]onvrdisplayactivate
[我来译!]onvrdisplayblur
[我来译!]onvrdisplayconnect
[我来译!]onvrdisplaydeactivate
[我来译!]onvrdisplaydisconnect
[我来译!]onvrdisplayfocus
[我来译!]onvrdisplaypresentchange
[我来译!]onwheel
opener
origin
[我来译!]outerHeight
outerWidth
parent
performance
personalbar
[我来译!]pkcs11
[我来译!]screen
screenX
screenY
scrollbars
[我来译!]scrollMaxX
[我来译!]scrollMaxY
[我来译!]scrollX
scrollY
self
sessionStorage
sidebar
speechSynthesis
[我来译!]status
[我来译!]statusbar
[我来译!]toolbar
[我来译!]top
URL
window
[我来译!]
- 方法
alert
atob
back()
blur()
btoa
cancelAnimationFrame
cancelIdleCallback()
[我来译!]captureEvents()
clearImmediate
clearInterval()
clearTimeout()
close
confirm()
convertPointFromNodeToPage()
[我来译!]convertPointFromPageToNode
[我来译!]createImageBitmap()
[我来译!]dump()
[我来译!]event
[我来译!]fetch()
find
focus()
[我来译!]forward()
[我来译!]getAttention()
[我来译!]getComputedStyle()
getDefaultComputedStyle()
getSelection
home()
[我来译!]matchMedia()
minimize
moveBy()
moveTo
open
openDialog
postMessage
print
prompt
releaseEvents
requestAnimationFrame
requestIdleCallback
resizeBy()
resizeTo
restore()
[我来译!]routeEvent()
[我来译!]scroll()
scrollBy()
[我来译!]scrollByLines()
[我来译!]scrollByPages
scrollTo()
setCursor()
[我来译!]setImmediate
setInterval
setTimeout
showModalDialog()
sizeToContent()
[我来译!]stop()
updateCommands()
[我来译!]
The
window
object represents a window containing a DOM document; thedocument
property points to the DOM document loaded in that window. A window for a given document can be obtained using thedocument.defaultView
property.This section provides a brief reference for all of the methods, properties, and events available through the DOM
window
object. Thewindow
object implements theWindow
interface, which in turn inherits from theAbstractView
interface. Some additional global functions, namespaces objects, interfaces, and constructors, not typically associated with the window, but available on it, are listed in the JavaScript Reference and DOM Reference.In a tabbed browser, such as Firefox, each tab contains its own
window
object (and if you're writing an extension, the browser window itself is a separate window too - see Working with windows in chrome code for more information). That is, thewindow
object is not shared between tabs in the same window. Some methods, namelywindow.resizeTo
andwindow.resizeBy
apply to the whole window and not to the specific tab thewindow
object belongs to. Generally, anything that can't reasonably pertain to a tab pertains to the window instead.Properties
This interface inherits properties from the
EventTarget
interface and implements properties fromWindowTimers
,WindowBase64
, andWindowEventHandlers
.Note that properties which are objects (e.g.,. for overriding the prototype of built-in elements) are listed in a separate section below.
Window.applicationCache
只读- An
OfflineResourceList
object providing access to the offline resources for the window. Window.closed
只读- This property indicates whether the current window is closed or not.
Window.Components
- The entry point to many XPCOM features. Some properties, e.g. classes, are only available to sufficiently privileged code. Web code should not use this property.
Window.console
只读- Returns a reference to the console object providing access to the browser's debugging console.
Window.content
and Window._content 只读- Returns a reference to the content element in the current window. The obsolete variant with underscore is no longer available from Web content.
Window.controllers
只读- Returns the XUL controller objects for the current chrome window.
Window.crypto
只读- Returns the browser crypto object.
Window.defaultStatus
已废弃 Gecko 23- Gets/sets the status bar text for the given window.
Window.devicePixelRatio
只读- Returns the ratio between physical pixels and device independent pixels in the current display.
Window.dialogArguments
只读- Gets the arguments passed to the window (if it's a dialog box) at the time
window.showModalDialog()
was called. This is annsIArray
. Window.directories
- Synonym of
window.personalbar
Window.document
只读- Returns a reference to the document that the window contains.
Window.frameElement
只读- Returns the element in which the window is embedded, or null if the window is not embedded.
Window.frames
只读- Returns an array of the subframes in the current window.
Window.fullScreen
- This property indicates whether the window is displayed in full screen or not.
已废弃 Gecko 13window.globalStorage
- Unsupported since Gecko 13 (Firefox 13). Use
Window.localStorage
instead.
Was: Multiple storage objects that are used for storing data across multiple pages. Window.history
只读- Returns a reference to the history object.
Window.innerHeight
- Gets the height of the content area of the browser window including, if rendered, the horizontal scrollbar.
window.innerWidth
- Gets the width of the content area of the browser window including, if rendered, the vertical scrollbar.
Window.length
只读- Returns the number of frames in the window. See also
window.frames
. Window.location
只读- Gets/sets the location, or current URL, of the window object.
Window.locationbar
只读- Returns the locationbar object, whose visibility can be toggled in the window.
Window.localStorage
只读- Returns a reference to the local storage object used to store data that may only be accessed by the origin that created it.
Window.menubar
只读- Returns the menubar object, whose visibility can be toggled in the window.
Window.messageManager
- Returns the message manager object for this window.
Window.mozAnimationStartTime
只读- The time in milliseconds since epoch at which the current animation cycle began.
Window.mozInnerScreenX
只读- Returns the horizontal (X) coordinate of the top-left corner of the window's viewport, in screen coordinates. This value is reported in CSS pixels. See
mozScreenPixelsPerCSSPixel
innsIDOMWindowUtils
for a conversion factor to adapt to screen pixels if needed. Window.mozInnerScreenY
只读- Returns the vertical (Y) coordinate of the top-left corner of the window's viewport, in screen coordinates. This value is reported in CSS pixels. See
mozScreenPixelsPerCSSPixel
for a conversion factor to adapt to screen pixels if needed. Window.mozPaintCount
只读- Returns the number of times the current document has been rendered to the screen in this window. This can be used to compute rendering performance.
Window.name
- Gets/sets the name of the window.
Window.navigator
只读- Returns a reference to the navigator object.
Window.opener
- Returns a reference to the window that opened this current window.
Window.outerHeight
只读- Gets the height of the outside of the browser window.
Window.outerWidth
只读- Gets the width of the outside of the browser window.
Window.pageXOffset
只读- An alias for
window.scrollX
. Window.pageYOffset
只读- An alias for
window.scrollY
Window.sessionStorage
只读- Returns a reference to the session storage object used to store data that may only be accessed by the origin that created it.
SpeechSynthesisGetter.speechSynthesis
只读Window.parent
只读- Returns a reference to the parent of the current window or subframe.
Window.performance
只读- Provides a hosting area for performance related attributes.
Window.personalbar
只读- Returns the personalbar object, whose visibility can be toggled in the window.
Window.pkcs11
已废弃 Gecko 29- Formerly provided access to install and remove PKCS11 modules.
Window.returnValue
- The return value to be returned to the function that called
window.showModalDialog()
to display the window as a modal dialog. Window.screen
只读- Returns a reference to the screen object associated with the window.
Window.screenX
只读- Returns the horizontal distance of the left border of the user's browser from the left side of the screen.
Window.screenY
只读- Returns the vertical distance of the top border of the user's browser from the top side of the screen.
Window.scrollbars
只读- Returns the scrollbars object, whose visibility can be toggled in the window.
Window.scrollMaxX
只读- The maximum offset that the window can be scrolled to horizontally, that is the document width minus the viewport width.
Window.scrollMaxY
只读- The maximum offset that the window can be scrolled to vertically (i.e., the document height minus the viewport height).
Window.scrollX
只读- Returns the number of pixels that the document has already been scrolled horizontally.
Window.scrollY
只读- Returns the number of pixels that the document has already been scrolled vertically.
Window.self
只读- Returns an object reference to the window object itself.
Window.sessionStorage
- Returns a storage object for storing data within a single page session.
Window.sidebar
只读- Returns a reference to the window object of the sidebar.
Window.status
- Gets/sets the text in the statusbar at the bottom of the browser.
Window.statusbar
只读- Returns the statusbar object, whose visibility can be toggled in the window.
Window.toolbar
只读- Returns the toolbar object, whose visibility can be toggled in the window.
Window.top
只读- Returns a reference to the topmost window in the window hierarchy. This property is read only.
Window.window
只读- Returns a reference to the current window.
window[0]
,window[1]
, etc.- Returns a reference to the
window
object in the frames. SeeWindow.frames
for more details.
Constructors
See also the DOM Interfaces.
Window.DOMParser
FIXME: NeedsContents Window.GeckoActiveXObject
FIXME: NeedsContents Image
Used for creating an HTMLImageElement
. Option
Used for creating an HTMLOptionElement
Window.QueryInterface
FIXME: NeedsContents Window.XMLSerializer
FIXME: NeedsContents Worker
Used for creating a Web worker Window.XPCNativeWrapper
FIXME: NeedsContents Window.XPCSafeJSObjectWrapper
FIXME: NeedsContents
Event handlers
These are properties of the window object that can be set to establish event handlers for the various things that can happen in the window that might be of interest.
This interface inherits event handlers from the EventTarget
interface and implements event handlers from WindowTimers
, WindowBase64
, and WindowEventHandlers
.
Note: Starting in Gecko 9.0, you can now use the syntax if ("onabort" in window)
to determine whether or not a given event handler property exists. This is because event handler interfaces have been updated to be proper web IDL interfaces. See DOM event handlers for details.
GlobalEventHandlers.onabort
An event handler property for abort events on the window. WindowEventHandlers.onbeforeunload
An event handler property for before-unload events on the window. GlobalEventHandlers.onblur
An event handler property for blur events on the window. GlobalEventHandlers.onchange
An event handler property for change events on the window. GlobalEventHandlers.onclick
An event handler property for click events on the window. GlobalEventHandlers.onclose
An event handler property for handling the window close event. GlobalEventHandlers.oncontextmenu
An event handler property for right-click events on the window. Window.ondevicelight
An event handler property for any ambient light levels changes Window.ondevicemotion
FIXME: NeedsContents Window.ondeviceorientation
An event handler property for any device orientation changes Window.ondeviceproximity
An event handler property for device proximity event GlobalEventHandlers.onerror
An event handler property for error
events raised on the window. GlobalEventHandlers.onfocus
An event handler property for focus
events on the window. WindowEventHandlers.onhashchange
An event handler property for hash change events on the window; called when the part of the URL after the hash mark ("#") changes. GlobalEventHandlers.onkeydown
An event handler property for keydown
events on the window. GlobalEventHandlers.onkeypress
An event handler property for keypress
events on the window. GlobalEventHandlers.onkeyup
An event handler property for keyup
events on the window. WindowEventHandlers.onlanguagechange
An event handler property for languagechange
events on the window. GlobalEventHandlers.onload
An event handler property for window loading. GlobalEventHandlers.onmousedown
An event handler property for mousedown events on the window. GlobalEventHandlers.onmousemove
An event handler property for mousemove events on the window. GlobalEventHandlers.onmouseout
An event handler property for mouseout events on the window. GlobalEventHandlers.onmouseover
An event handler property for mouseover events on the window. GlobalEventHandlers.onmouseup
An event handler property for mouseup events on the window. Window.onmozbeforepaint
An event handler property for the MozBeforePaint
event, which is sent before repainting the window if the event has been requested by a call to the Window.mozRequestAnimationFrame()
method. WindowEventHandlers.onpageshow
An event handler property for pageshow events on the window. WindowEventHandlers.onpagehide
An event handler property for pagehide events on the window. Window.onpaint
An event handler property for paint events on the window. WindowEventHandlers.onpopstate
An event handler property for popstate events, which are fired when navigating to a session history entry representing a state object. GlobalEventHandlers.onreset
An event handler property for reset events on the window. GlobalEventHandlers.onresize
An event handler property for window resizing. GlobalEventHandlers.onscroll
An event handler property for window scrolling. GlobalEventHandlers.onselect
An event handler property for window selection. GlobalEventHandlers.onsubmit
An event handler property for submits on window forms. Window.onunload
An event handler property for unload events on the window. Window.onuserproximity
An event handler property for user proximity events
Methods
This interface inherits methods from the EventTarget
interface and implements methods from WindowTimers
, WindowBase64
, and WindowEventHandlers
.
EventTarget.addEventListener()
Register an event handler to a specific event type on the window. Window.alert()
Displays an alert dialog. WindowBase64.atob()
Decodes a string of data which has been encoded using base-64 encoding. Window.back()
Moves back one in the window history. Window.blur()
Sets focus away from the window. WindowBase64.btoa()
Creates a base-64 encoded ASCII string from a string of binary data. Window.captureEvents()
Registers the window to capture all events of the specified type. Window.clearImmediate()
Cancels the repeated execution set using setImmediate
. WindowTimers.clearInterval()
Cancels the repeated execution set using WindowTimers.setInterval()
. WindowTimers.clearTimeout()
Cancels the repeated execution set using WindowTimers.setTimeout()
. Window.close()
Closes the current window. Window.confirm()
Displays a dialog with a message that the user needs to respond to. Window.disableExternalCapture()
已废弃 Gecko 24 FIXME: NeedsContents Window.dispatchEvent()
Used to trigger an event. Window.dump()
Writes a message to the console. Window.enableExternalCapture()
已废弃 Gecko 24 FIXME: NeedsContents Window.find()
Searches for a given string in a window. Window.focus()
Sets focus on the current window. Window.forward()
Moves the window one document forward in the history. Window.getAttention()
Flashes the application icon. Window.getAttentionWithCycleCount()
FIXME: NeedsContents Window.getComputedStyle()
Gets computed style for the specified element. Computed style indicates the computed values of all CSS properties of the element. Window.getDefaulComputedStyle()
Gets default computed style for the specified element, ignoring author stylesheets. Window.getSelection()
Returns the selection object representing the selected item(s). Window.home()
Returns the browser to the home page. Window.matchMedia()
Returns a MediaQueryList
object representing the specified media query string. Window.maximize()
FIXME: NeedsContents Window.minimize()
(top-level XUL windows only) Minimizes the window. Window.moveBy()
Moves the current window by a specified amount. Window.moveTo()
Moves the window to the specified coordinates. Window.mozRequestAnimationFrame()
Tells the browser that an animation is in progress, requesting that the browser schedule a repaint of the window for the next animation frame. This will cause a MozBeforePaint
event to fire before that repaint occurs. Window.open()
Opens a new window. Window.openDialog()
Opens a new dialog window. Window.postMessage()
Provides a secure means for one window to send a string of data to another window, which need not be within the same domain as the first. Window.print()
Opens the Print Dialog to print the current document. Window.prompt()
Returns the text entered by the user in a prompt dialog. Window.releaseEvents()
Releases the window from trapping events of a specific type. Window.removeEventListener()
Removes an event listener from the window. Window.resizeBy()
Resizes the current window by a certain amount. Window.resizeTo()
Dynamically resizes window. Window.restore()
FIXME: NeedsContents Window.routeEvent()
已废弃 Gecko 24 FIXME: NeedsContents Window.scroll()
Scrolls the window to a particular place in the document. Window.scrollBy()
Scrolls the document in the window by the given amount. Window.scrollByLines()
Scrolls the document by the given number of lines. Window.scrollByPages()
Scrolls the current document by the specified number of pages. Window.scrollTo()
Scrolls to a particular set of coordinates in the document. Window.setCursor()
Changes the cursor for the current window Window.setImmediate()
Executes a function after the browser has finished other heavy tasks WindowTimers.setInterval()
Schedules the execution of a function each X milliseconds. Window.setResizable
FIXME: NeedsContents WindowTimers.setTimeout()
Sets a delay for executing a function. Window.showModalDialog()
Displays a modal dialog. Window.sizeToContent()
Sizes the window according to its content. Window.stop()
This method stops window loading. Window.updateCommands()
Updates the state of commands of the current chrome window (UI).