DOM:window
From MDC
本节为 DOM window 中可用的所有方法、属性和事件提供简要的参考。window 对象实现了 Window 接口,此接口继承自 AbstractView 接口。
window 对象用于表示窗口自身。window 的 document 属性指向窗口中所载入的 DOM document 。可以通过使用 document.defaultView 属性来获取给定文档的窗口。
在 FireFox 之类的标签浏览器中,每个标签都有其自己的 window 对象(如果你在编写扩展的话,浏览器窗口也是一个单独的窗口——详情参见 Working with windows in chrome code)。也就是说,同一个窗口中的两个标签并不共用一个 window 对象。有几个方法,如 window.resizeTo 和 window.resizeBy 之类的方法会作用于整个窗口而不是该 window 对象所属的那个标签。一般而言,如果无法恰当地作用于标签,则会将其作用于窗口。
[编辑] 属性
- window.Components
- The entry point to many XPCOM features. Some properties, e.g. classes, are only available to sufficiently privileged code.
- window.content and window._content
- Returns a reference to the content element in the current window. The variant with underscore is deprecated.
- window.closed
- This property indicates whether the current window is closed or not.
- window.controllers
- Returns the XUL controller objects for the current chrome window.
- window.crypto
- Returns the browser crypto object.
- window.defaultStatus
- Gets/sets the status bar text for the given window.
- window.dialogArguments New in Firefox 3
- Gets the arguments passed to the window (if it's a dialog box) at the time
window.showModalDialog()was called. This is an Template:interface.
- window.directories
- Returns a reference to the directories toolbar in the current chrome.
- 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 New in Firefox 3
- This property indicates whether the window is displayed in full screen or not.
- window.globalStorage New in Firefox 2
- 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.
- 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.menubar
- Returns the menubar object, whose visibility can be toggled in the window.
- 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.parent
- Returns a reference to the parent of the current window or subframe.
- window.personalbar
- Returns the personalbar object, whose visibility can be toggled in the window.
- window.pkcs11
- Returns the pkcs11 object, which can be used to install drivers and other software associated with the pkcs11 protocol.
- window.returnValue New in Firefox 3
- 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.screen.availTop
- Specifies the y-coordinate of the first pixel that is not allocated to permanent or semipermanent user interface features.
- window.screen.availLeft
- Returns the first available pixel available from the left side of the screen.
- window.screen.availHeight
- Specifies the height of the screen, in pixels, minus permanent or semipermanent user interface features displayed by the operating system, such as the Taskbar on Windows.
- window.screen.availWidth
- Returns the amount of horizontal space in pixels available to the window.
- window.screen.colorDepth
- Returns the color depth of the screen.
- window.screen.height
- Returns the height of the screen in pixels.
- window.screen.left
- Returns the current distance in pixels from the left side of the screen.
- window.screen.pixelDepth
- Gets the bit depth of the screen.
- window.screen.top
- Returns the distance from the top of the screen.
- window.screen.width
- Returns the width of the screen.
- 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.
- (i.e., 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 New in Firefox 3
- 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.
- window.window
- Returns a reference to the current window.
[编辑] 方法
- window.alert
- Displays an alert dialog.
- window.addEventListener
- Register an event handler to a specific event type on the window.
- window.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.
- window.btoa
- Creates a base-64 encoded ASCII string from a string of binary data.
- window.captureEvents Template:obsolete inline
- Registers the window to capture all events of the specified type.
- window.clearInterval
- Cancels the repeated execution set using
setInterval.
- window.clearTimeout
- Clears a delay that's been set for a specific function.
- window.close
- Closes the current window.
- window.confirm
- Displays a dialog with a message that the user needs to respond to.
- window.dump
- Writes a message to the console.
- window.escape
- Encodes a string.
- 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.getComputedStyle
- Gets computed style for the specified element. Computed style indicates the computed values of all CSS properties of the element.
- window.getSelection
- Returns the selection object representing the selected item(s).
- window.home
- Returns the browser to the home page.
- window.moveBy
- Moves the current window by a specified amount.
- window.moveTo
- Moves the window to the specified coordinates.
- window.open
- Opens a new window.
- window.openDialog
- Opens a new dialog window.
- 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 Template:obsolete inline
- 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.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.setInterval
- Execute a function each X milliseconds.
- window.setTimeout
- Sets a delay for executing a function.
- window.showModalDialog New in Firefox 3
- Displays a modal dialog.
- window.sizeToContent
- Sizes the window according to its content.
- window.stop
- This method stops window loading.
- window.unescape
- Unencodes a value that has been encoded in hexadecimal (e.g. a cookie).
- window.updateCommands
- Updates the state of commands of the current chrome window (UI).
[编辑] 事件处理函数
- window.onabort
- window 的 abort 事件的事件处理函数。
- window.onbeforeunload
- window 的 before-unload 事件的事件处理函数。
- window.onblur
- window 的 blur 事件的事件处理函数。
- window.onchange
- window 的 change 事件的事件处理函数。
- window.onclick
- window 的 click 事件的事件处理函数。
- window.onclose
- window 的 close 事件的事件处理函数。
- window.oncontextmenu
- window 的 right-click 事件的事件处理函数。
- window.ondragdrop
- window 拖放事件的事件处理函数。
- window.onerror
- window 在发生错误时调用的事件处理函数。
- window.onfocus
- window 的 focus 事件的事件处理函数。
- window.onkeydown
- window 的 keydown 事件的事件处理函数。
- window.onkeypress
- window 的 keypress 事件的事件处理函数。
- window.onkeyup
- window 的 keyup 事件的事件处理函数。
- window.onload
- window 载入后触发的事件处理函数。
- window.onmousedown
- window 的 mousedown 事件的事件处理函数。
- window.onmousemove
- window 的 mousemove 事件的事件处理函数。
- window.onmouseout
- window 的 mouseout 事件的事件处理函数。
- window.onmouseover
- window 的 mouseover 事件的事件处理函数。
- window.onmouseup
- window 的 mouseup 事件的事件处理函数。
- window.onpaint
- window 的 paint 事件的事件处理函数。
- window.onreset
- window 的 reset 事件的事件处理函数。
- window.onresize
- window 大小改变时触发的事件处理函数。
- window.onscroll
- window 滚动条滚动时触发的事件处理函数。
- window.onselect
- An event handler property for window selection.
- window.onsubmit
- window 的表单提交时触发的事件处理函数。
- window.onunload
- window 的 unload 事件的事件处理函数。