nsIDOMWindow 编辑

dom/interfaces/base/nsIDOMWindow.idlScriptable 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

AttributeTypeDescription
applicationCachensIDOMOfflineResourceListGet the application cache object for this window. Read only. Note: Prior to Gecko 7.0 this attribute was part of nsIDOMWindow2.
documentnsIDOMDocumentThe document contained in the window. Read only.
framesnsIDOMWindowCollectionThe child windows for this window. Read only. Native code only!
globalStoragensIDOMStorageListGlobal storage, accessible by domain. Read only. Note: Prior to Gecko 8.0 this attribute was part of nsIDOMStorageWindow.
localStoragensIDOMStorageLocal 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.
nameDOMStringGet or set the name of this window. This attribute is "replaceable" in JavaScript.
parentnsIDOMWindowThe 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.
scrollXlongThe current horizontal (x) scroll position, in pixels. This attribute is "replaceable" in JavaScript. Read only.
scrollYlongThe current vertical (y) scroll position, in pixels. This attribute is "replaceable" in JavaScript. Read only.
scrollbarsnsIDOMBarPropThe object that controls whether or not scrollbars are shown in the window. This attribute is "replaceable" in JavaScript. Read only.
sessionStoragensIDOMStorageSession 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.
textZoomfloatGet 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!
topnsIDOMWindowThe 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.
windowRootnsIDOMEventTargetThe 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:121 次

字数:12353

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文