JavaScript Window : Global
window property and all properties on the
Window are available directly in scripts. The Window object is also available as this in the root
scope of a script (ie, outside of any Function).
Instance Properties
Provides a way to extend HTML/DOM with your own elements that have custom logic similar to built in elements. See also CustomElementPrototype.
Example:
RunResults:
Height of the browser window in CSS pixels excluding any browser chrome.
Example:
RunResults:
Width of the browser window in CSS pixels exluding any browser chrome.
Example:
RunResults:
localStorage allows saving data in the web browser that can be retrieved in future views of the web
page. The data is saved across browser sessions and computer reboots. See also sessionStorage and Storage for more details.
Example:
RunResults:
Height of the browser window in CSS pixels including any browser chrome.
Example:
RunResults:
Width of the browser window in CSS pixels including any browser chrome.
Example:
RunResults:
sessionStorage allows saving data in the web browser that can be retrieved in future views of the web
page. The data is only saved for the current session, that is until the user closes the web browser. See also localStorage and Storage for more details.
Example:
RunResults:
Returns the global object for the browser. Also available through the self
property, through this in the root scope, and through the globalThis property (in ECMAScript 2020).
Example:
RunResults:
Instance Methods
Stops an animation frame callback from running. handle is the value returned by requestAnimationFrame().
Example:
RunResults:
Stops an setInterval() callback from running. handle is the
value returned by setInterval().
Example:
RunResults:
| imageOrientation | String | One of 'none' or 'flipY'. Default is 'none'. |
| premultiplyAlpha | String | One of 'none', 'premultiply', or 'default'. Default is
'default'. |
| colorSpaceConversion | String | One of 'none' or 'default'. Default is 'default'. |
| resizeWidth | Number | |
| resizeHeight | Number | |
| resizeQuality | String | One of 'pixelated', 'low', 'medium', or 'high'.
Default is 'low'. |
Example:
RunResults:
| imageOrientation | String | One of 'none' or 'flipY'. Default is 'none'. |
| premultiplyAlpha | String | One of 'none', 'premultiply', or 'default'. Default is
'default'. |
| colorSpaceConversion | String | One of 'none' or 'default'. Default is 'default'. |
| resizeWidth | Number | |
| resizeHeight | Number | |
| resizeQuality | String | One of 'pixelated', 'low', 'medium', or 'high'.
Default is 'low'. |
Example:
RunResults:
| imageOrientation | String | One of 'none' or 'flipY'. Default is 'none'. |
| premultiplyAlpha | String | One of 'none', 'premultiply', or 'default'. Default is
'default'. |
| colorSpaceConversion | String | One of 'none' or 'default'. Default is 'default'. |
| resizeWidth | Number | |
| resizeHeight | Number | |
| resizeQuality | String | One of 'pixelated', 'low', 'medium', or 'high'.
Default is 'low'. |
Example:
RunResults:
| imageOrientation | String | One of 'none' or 'flipY'. Default is 'none'. |
| premultiplyAlpha | String | One of 'none', 'premultiply', or 'default'. Default is
'default'. |
| colorSpaceConversion | String | One of 'none' or 'default'. Default is 'default'. |
| resizeWidth | Number | |
| resizeHeight | Number | |
| resizeQuality | String | One of 'pixelated', 'low', 'medium', or 'high'.
Default is 'low'. |
Example:
RunResults:
| imageOrientation | String | One of 'none' or 'flipY'. Default is 'none'. |
| premultiplyAlpha | String | One of 'none', 'premultiply', or 'default'. Default is
'default'. |
| colorSpaceConversion | String | One of 'none' or 'default'. Default is 'default'. |
| resizeWidth | Number | |
| resizeHeight | Number | |
| resizeQuality | String | One of 'pixelated', 'low', 'medium', or 'high'.
Default is 'low'. |
Example:
RunResults:
| imageOrientation | String | One of 'none' or 'flipY'. Default is 'none'. |
| premultiplyAlpha | String | One of 'none', 'premultiply', or 'default'. Default is
'default'. |
| colorSpaceConversion | String | One of 'none' or 'default'. Default is 'default'. |
| resizeWidth | Number | |
| resizeHeight | Number | |
| resizeQuality | String | One of 'pixelated', 'low', 'medium', or 'high'.
Default is 'low'. |
Example:
RunResults:
Example:
RunResults:
| imageOrientation | String | One of 'none' or 'flipY'. Default is 'none'. |
| premultiplyAlpha | String | One of 'none', 'premultiply', or 'default'. Default is
'default'. |
| colorSpaceConversion | String | One of 'none' or 'default'. Default is 'default'. |
| resizeWidth | Number | |
| resizeHeight | Number | |
| resizeQuality | String | One of 'pixelated', 'low', 'medium', or 'high'.
Default is 'low'. |
Example:
RunResults:
Computes the effective style for element including all CSS rules that apply to element.
See also element.style.
Example:
RunResults:
Opens a new tab or window for the specified url.
-
url -
the url to open or
''to open an empty window. -
target -
must be one of:
'_blank'- open in new window, the default
'_parent'- open in parent page/frame
'_self'- open in current page/frame
'_top'- open in top page
'<name>'- open in the window with the specified name
-
features -
is a comma separated list of
'<name>=<value>'pairs where the valid names are'left','top','height','width'. -
replace -
pass
trueto replace the contents instead of opening a new window.
Example:
RunResults:
Sends message to this (usually something other than the global
window, like the parent, iframe
contentwindow, or return value of
open()). The message will be available in the
MessageEvent.data property on the event passed to
the onmessage event listener. To ensure the window's content has
not changed while the message is in flight, expectedOrigin must match
this.origin (or be '*' to ignore check and
possibly send the message to another site). The elements of
objectsToTransfer will be transferred to the JavaScript context that
owns this and no longer available in the context that called
postMessage().
See also MessageChannel.
Example:
RunResults:
Displays a message box containing an input box to the user with the specified message. The input box will be
prepopulated with default if it is specified. Returns the String the user typed in the input box if
the user clicks ok and null if they click cancel. Script execution is paused while the message box is
displayed. See also alert() and confirm().
Example:
RunResults:
Schedules callback to be called before the next time the browser renders a frame to the screen. Must
be called each time you'd like to schedule another frame. The time parameter to callback is the
number of milliseconds since the page loaded. Returns a unique handle that can be passed to cancelAnimationFrame() to stop callback from being
called.
Example:
RunResults:
Schedules callback to be called repeatedly, every timeout milliseconds. Any extra
parameters after timeout are passed to callback. Returns a unique handle that can be
passed to clearInterval() to stop callback from being
called. See also setTimeout() and requestAnimationFrame().
Example:
RunResults:
Same as setInterval() where the callback string
is passed to eval when the time has elapsed.
Schedules callback to be called once after timeout milliseconds. Any extra
parameters after timeout are passed to callback. Returns a unique handle that can be
passed to clearTimeout() to stop callback from being
called. See also setInterval() and requestAnimationFrame().
Example:
RunResults:
Same as setTimeout() where the callback string is
passed to eval when the time has elapsed.
Instance Events
Called before the page is navigated away from. Return a non-empty String from listener to display a
dialog box that gives the user the option to remain on the current page.