nsIDOMWindow 编辑
dom/interfaces/base/nsIDOMWindow.idl
Scriptable This interface is the primary interface for a window object. It represents a single window object that may contain child windows if the document in the window contains an HTML frameset document, or if the document contains iframe elements. 66 Introduced Gecko 1.0 Deprecated Gecko 44 Inherits from: nsISupports
Last changed in Gecko 7.0 (Firefox 7.0 / Thunderbird 7.0 / SeaMonkey 2.4)Starting with Firefox 44, this file is empty as its features were either no longer used or are only available from C++ code; see dom/base/nsPIDOMWindow.h
for those.
While this interface is not officially defined by any standard bodies, it originates from the de-facto DOM Level 0 standard.
Starting in Firefox 3, DOM windows are actually based on nsIDOMWindow2
, which is a subclass of nsIDOMWindow
that adds some new features to this interface.
In Gecko 7.0 nsIDOMWindow2
has been merged into this interface.
In Gecko 8.0 nsIDOMStorageWindow
and nsIDOMWindowInternal
have been merged into this interface.
Method overview
nsIDOMCSSStyleDeclaration getComputedStyle(in nsIDOMElement elt, [optional] in DOMString pseudoElt); |
nsISelection getSelection(); |
void scrollBy(in long xScrollDif, in long yScrollDif); |
void scrollByLines(in long numLines); |
void scrollByPages(in long numPages); |
void scrollTo(in long xScroll, in long yScroll); |
void sizeToContent(); |
Attributes
Attribute | Type | Description |
applicationCache | nsIDOMOfflineResourceList | Get the application cache object for this window. Read only. Note: Prior to Gecko 7.0 this attribute was part of nsIDOMWindow2 . |
document | nsIDOMDocument | The document contained in the window. Read only. |
frames | nsIDOMWindowCollection | The child windows for this window. Read only. Native code only! |
globalStorage | nsIDOMStorageList | Global storage, accessible by domain. Read only. Note: Prior to Gecko 8.0 this attribute was part of nsIDOMStorageWindow . |
localStorage | nsIDOMStorage | Local storage for the current browsing context. Data stored in local storage may only be accessed from the same origin that inserted the data into storage in the first place. Read only. Note: Prior to Gecko 8.0 this attribute was part of nsIDOMStorageWindow . |
name | DOMString | Get or set the name of this window. This attribute is "replaceable" in JavaScript. |
parent | nsIDOMWindow | The window's parent window. If there is no parent window, or if the parent is of a different type, this is the current window. The window hierarchy does not cross chrome-content boundaries. Read only. |
scrollX | long | The current horizontal (x) scroll position, in pixels. This attribute is "replaceable" in JavaScript. Read only. |
scrollY | long | The current vertical (y) scroll position, in pixels. This attribute is "replaceable" in JavaScript. Read only. |
scrollbars | nsIDOMBarProp | The object that controls whether or not scrollbars are shown in the window. This attribute is "replaceable" in JavaScript. Read only. |
sessionStorage | nsIDOMStorage | Session storage for the current browsing context. Data stored in session storage may be accessed by any site in the browsing context. Read only.Note: Prior to Gecko 8.0 this attribute was part of nsIDOMStorageWindow . |
textZoom | float | Get or set the document scale factor as a multiplier of the default size. When setting this attribute, an NS_ERROR_NOT_IMPLEMENTED error may be returned by implementations not supporting zoom. This attribute should always return 1.0 for implementations not supporting text zoom. 1.0 represents normal (unzoomed) size. Native code only! |
top | nsIDOMWindow | The root window for the hierarchy of windows that contain this nsIDOMWindow . This is the window itself if there is no parent, or if the parent is of a different type. The window hierarchy does not cross chrome-content boundaries. This attribute is "replaceable" in JavaScript. Read only. |
windowRoot | nsIDOMEventTarget | The window root for this window. This is useful for connecting event listeners to this window as well as every other window nested in that window root. Read only. Native code only! Note: Prior to Gecko 7.0 this attribute was part of nsIDOMWindow2 . |
Methods
getComputedStyle()
See dom-window-getcomputedstyle for details.
nsIDOMCSSStyleDeclaration getComputedStyle( in nsIDOMElement elt, in DOMString pseudoElt Optional );
Parameters
elt
pseudoElt
Optional
Return value
getSelection()
Returns the nsISelection
object indicating what if any content is currently selected in the window.
nsISelection getSelection();
Parameters
None.
Return value
The nsISelection
object for the window.
scrollBy()
Scrolls the window by a given number of pixels relative to the current scroll position.
void scrollBy( in long xScrollDif, in long yScrollDif );
Parameters
xScrollDif
- The number of pixels by which to scroll horizontally.
yScrollDif
- The number of pixels by which to scroll vertically.
scrollByLines()
Scrolls the window by the specified number of lines.
void scrollByLines( in long numLines );
Parameters
numLines
- The number of lines by which to scroll.
scrollByPages()
Scrolls the window by the specified number of pages.
void scrollByPages( in long numPages );
Parameters
numPages
- The number of pages by which to scroll.
scrollTo()
Scrolls the window to an absolute pixel offset.
void scrollTo( in long xScroll, in long yScroll );
Parameters
xScroll
- The horizontal position to which to scroll, in pixels.
yScroll
- The vertical position to which to scroll, in pixels.
sizeToContent()
Makes the window's size fit the contents of the window.
void sizeToContent();
Parameters
None.
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论