Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

nsIDOMWindow

Nos bénévoles n'ont pas encore traduit cet article en Français. Aidez-nous à réaliser cette tâche !

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.
47
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.

Firefox 3 note

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.

Gecko 7.0 note

In Gecko 7.0 nsIDOMWindow2 has been merged into this interface.

Gecko 8.0 note

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

Étiquettes et contributeurs liés au document

 Contributeurs à cette page : Sheppy, Wladimir_Palant, trevorh, Dao
 Dernière mise à jour par : Sheppy,