Window

Module: JavaScript DOM API

The window of the view and the global object in the scripting environment.

#include <Window.idl>

Inherits from EventTarget

Public Functions

Name
voidscrollBy(optional long x, optional long y)
Scrolls the document in the window by the given amount.
voidscrollTo(optional long x, optional long y)
Scrolls to a particular set of coordinates in the document.
unsigned longsetTimeout(AnyCallbackTraced handler, optional unsigned long timeout)
schedule a callback to be executed after timeout milliseconds
voidclearTimeout(unsigned long handle)
clear a previous scheduled timer
unsigned longsetInterval(AnyCallbackTraced handler, unsigned long interval)
schedule a callback to be executed at timeout milliseconds intervals
voidclearInterval(unsigned long handle)
clear a previous scheduled repeating timer
CSSStyleDeclarationgetComputedStyle(Element element)
the last computed style of the element
longrequestAnimationFrame(AnyCallbackTraced callback)
voidcancelAnimationFrame(long id)
Cancels an animation frame request previously scheduled through a call to requestAnimationFrame()
voidaddEventListener(DOMInternedString type, EventListener listener, optional boolean useCapture)
voidremoveEventListener(DOMInternedString type, EventListener listener, optional boolean useCapture)
voidqueueMicrotask(AnyCallbackTraced callback)
Schedules a call to the specified callback after the function that enqueues the microtask has finished.
booleandispatchEvent(Event event)
SelectiongetSelection()
Returns a Selection object representing the range of text selected by the user, or the current position of the caret.

Public Attributes

Name
readonly attribute Documentdocument
The document in the current window.
readonly attribute Consoleconsole
The console API that can be used for logging.
readonly attribute CoherentDebugcohDebug
The Coherent Debug object used to control various CoHTML options.
readonly attribute Performanceperformance
readonly attribute Locationlocation
readonly attribute Navigatornavigator
readonly attribute Windowself
readonly attribute StoragelocalStorage
readonly attribute Historyhistory
readonly attribute Windowparent
A reference to the parent of the current window or subframe.
readonly attribute Screenscreen
readonly attribute CustomElementRegistrycustomElements
Gets the CustomElementRegistry that can be used to register new custom or get information about registered custom elements.
readonly attribute longouterHeight
Gets the height in pixels of the whole browser window. It represents the height of the whole browser window including sidebar (if expanded), window chrome and window resizing borders/handles.
readonly attribute longouterWidth
Gets the width of the outside of the browser window. It represents the width of the whole browser window including sidebar (if expanded), window chrome and window resizing borders/handles.
readonly attribute longinnerHeight
Height (in pixels) of the browser window viewport including, if rendered, the horizontal scrollbar.
readonly attribute longinnerWidth
Width (in pixels) of the browser window viewport including, if rendered, the vertical scrollbar.
readonly attribute longscreenX
Returns the horizontal distance, in CSS pixels, of the left border of the user’s browser from the left side of the screen.
readonly attribute longscreenY
Returns the vertical distance, in CSS pixels of the top border of the user’s browser from the top edge of the screen.
readonly attribute longscreenLeft
This is an alias for screenX.
readonly attribute longscreenTop
This is an alias for screenY.
readonly attribute longscrollX
Returns the number of pixels that the document has already been scrolled horizontally.
readonly attribute longscrollY
Returns the number of pixels that the document has already been scrolled vertically.
readonly attribute longpageXOffset
This is an alias for scrollX.
readonly attribute longpageYOffset
This is an alias for scrollY.
readonly attribute doubledevicePixelRatio
Returns the ratio of the CSS pixel size to device pixel size.
readonly attribute Chromechrome
attribute EventSettergamepadconnected
attribute EventSettergamepaddisconnected
attribute EventSetterpopstate
attribute EventSetterresize
attribute EventSetterunhandledrejection
attribute EventSetterabort
attribute EventSetterblur
attribute EventSetterclick
attribute EventSetterauxclick
attribute EventSetterdblclick
attribute EventSettererror
attribute EventSetterfocus
attribute EventSetterkeydown
attribute EventSetterkeypress
attribute EventSetterkeyup
attribute EventSetterload
attribute EventSettermousedown
attribute EventSettermouseover
attribute EventSettermouseout
attribute EventSettermouseenter
attribute EventSettermouseleave
attribute EventSettermousemove
attribute EventSettermouseup
attribute EventSetterinput
attribute EventSetterscroll
attribute EventSetterwheel
attribute EventSettertouchstart
attribute EventSettertouchend
attribute EventSettertouchmove

Public Functions Documentation

function scrollBy

void scrollBy(
    optional long x,
    optional long y
)

Scrolls the document in the window by the given amount.

Parameters:

  • x offset in pixels to scroll horizontally.
  • y offset in pixels to scroll vertically.

function scrollTo

void scrollTo(
    optional long x,
    optional long y
)

Scrolls to a particular set of coordinates in the document.

Parameters:

  • x is the pixel along the horizontal axis of the document that you want displayed in the upper left.
  • y is the pixel along the vertical axis of the document that you want displayed in the upper left.

function setTimeout

unsigned long setTimeout(
    AnyCallbackTraced handler,
    optional unsigned long timeout
)

schedule a callback to be executed after timeout milliseconds

Parameters:

  • handler a callback without arguments
  • timeout the delay in milliseconds.

Return: a handle to the scheduled timer

Note: A 0 delay makes the callback to be executed on the next frame

function clearTimeout

void clearTimeout(
    unsigned long handle
)

clear a previous scheduled timer

Parameters:

  • handle a handle returned from setTimeout

function setInterval

unsigned long setInterval(
    AnyCallbackTraced handler,
    unsigned long interval
)

schedule a callback to be executed at timeout milliseconds intervals

Parameters:

  • handler a callback without arguments
  • interval the delay in milliseconds.

Return: a handle to the scheduled timer

Note: A 0 delay makes the callback to be executed on the next frame

The first call to the callback will be after timeout milliseconds

function clearInterval

void clearInterval(
    unsigned long handle
)

clear a previous scheduled repeating timer

Parameters:

  • handle a handle returned from setInterval

function getComputedStyle

CSSStyleDeclaration getComputedStyle(
    Element element
)

the last computed style of the element

Parameters:

  • element the element whose style to get

function requestAnimationFrame

long requestAnimationFrame(
    AnyCallbackTraced callback
)

function cancelAnimationFrame

void cancelAnimationFrame(
    long id
)

Cancels an animation frame request previously scheduled through a call to requestAnimationFrame()

Parameters:

  • id The ID of the request to cancel.

function addEventListener

void addEventListener(
    DOMInternedString type,
    EventListener listener,
    optional boolean useCapture
)

Reimplements: EventTarget::addEventListener

function removeEventListener

void removeEventListener(
    DOMInternedString type,
    EventListener listener,
    optional boolean useCapture
)

Reimplements: EventTarget::removeEventListener

function queueMicrotask

void queueMicrotask(
    AnyCallbackTraced callback
)

Schedules a call to the specified callback after the function that enqueues the microtask has finished.

Parameters:

  • callback The callback to be invoked.

function dispatchEvent

boolean dispatchEvent(
    Event event
)

Reimplements: EventTarget::dispatchEvent

function getSelection

Selection getSelection()

Returns a Selection object representing the range of text selected by the user, or the current position of the caret.

Public Attributes Documentation

variable document

readonly attribute Document document;

The document in the current window.

variable console

readonly attribute Console console;

The console API that can be used for logging.

variable cohDebug

readonly attribute CoherentDebug cohDebug;

The Coherent Debug object used to control various CoHTML options.

variable performance

readonly attribute Performance performance;

variable location

readonly attribute Location location;

variable navigator

readonly attribute Navigator navigator;

variable self

readonly attribute Window self;

variable localStorage

readonly attribute Storage localStorage;

variable history

readonly attribute History history;

variable parent

readonly attribute Window parent;

A reference to the parent of the current window or subframe.

Note: If a window does not have a parent, its parent property is a reference to itself.

variable screen

readonly attribute Screen screen;

variable customElements

readonly attribute CustomElementRegistry customElements;

Gets the CustomElementRegistry that can be used to register new custom or get information about registered custom elements.

variable outerHeight

readonly attribute long outerHeight;

Gets the height in pixels of the whole browser window. It represents the height of the whole browser window including sidebar (if expanded), window chrome and window resizing borders/handles.

variable outerWidth

readonly attribute long outerWidth;

Gets the width of the outside of the browser window. It represents the width of the whole browser window including sidebar (if expanded), window chrome and window resizing borders/handles.

variable innerHeight

readonly attribute long innerHeight;

Height (in pixels) of the browser window viewport including, if rendered, the horizontal scrollbar.

variable innerWidth

readonly attribute long innerWidth;

Width (in pixels) of the browser window viewport including, if rendered, the vertical scrollbar.

variable screenX

readonly attribute long screenX;

Returns the horizontal distance, in CSS pixels, of the left border of the user’s browser from the left side of the screen.

variable screenY

readonly attribute long screenY;

Returns the vertical distance, in CSS pixels of the top border of the user’s browser from the top edge of the screen.

variable screenLeft

readonly attribute long screenLeft;

This is an alias for screenX.

variable screenTop

readonly attribute long screenTop;

This is an alias for screenY.

variable scrollX

readonly attribute long scrollX;

Returns the number of pixels that the document has already been scrolled horizontally.

variable scrollY

readonly attribute long scrollY;

Returns the number of pixels that the document has already been scrolled vertically.

variable pageXOffset

readonly attribute long pageXOffset;

This is an alias for scrollX.

variable pageYOffset

readonly attribute long pageYOffset;

This is an alias for scrollY.

variable devicePixelRatio

readonly attribute double devicePixelRatio;

Returns the ratio of the CSS pixel size to device pixel size.

variable chrome

readonly attribute Chrome chrome;

variable gamepadconnected

attribute EventSetter gamepadconnected;

variable gamepaddisconnected

attribute EventSetter gamepaddisconnected;

variable popstate

attribute EventSetter popstate;

variable resize

attribute EventSetter resize;

variable unhandledrejection

attribute EventSetter unhandledrejection;

variable abort

attribute EventSetter abort;

variable blur

attribute EventSetter blur;

variable click

attribute EventSetter click;

variable auxclick

attribute EventSetter auxclick;

variable dblclick

attribute EventSetter dblclick;

variable error

attribute EventSetter error;

variable focus

attribute EventSetter focus;

variable keydown

attribute EventSetter keydown;

variable keypress

attribute EventSetter keypress;

variable keyup

attribute EventSetter keyup;

variable load

attribute EventSetter load;

variable mousedown

attribute EventSetter mousedown;

variable mouseover

attribute EventSetter mouseover;

variable mouseout

attribute EventSetter mouseout;

variable mouseenter

attribute EventSetter mouseenter;

variable mouseleave

attribute EventSetter mouseleave;

variable mousemove

attribute EventSetter mousemove;

variable mouseup

attribute EventSetter mouseup;

variable input

attribute EventSetter input;

variable scroll

attribute EventSetter scroll;

variable wheel

attribute EventSetter wheel;

variable touchstart

attribute EventSetter touchstart;

variable touchend

attribute EventSetter touchend;

variable touchmove

attribute EventSetter touchmove;