Window class

Top-level container for the current browser tab or window.

In a web browser, each window has a Window object, but within the context of a script, this object represents only the current window. Each other window, tab, and iframe has its own Window object.

Each window contains a Document object, which contains all of the window's content.

Use the top-level window object to access the current window. For example:

// Draw a scene when the window repaints.
drawScene(num delta) {...}
window.animationFrame.then(drawScene);.

// Write to the console.
window.console.log('Jinkies!');
window.console.error('Jeepers!');

Note: This class represents only the current window, while WindowBase is a representation of any window, including other tabs, windows, and frames.

See also

Other resources

Inheritance
Implemented types
Annotations
  • @Native("Window,DOMWindow")

Properties

animationFrameFuture<num>
read-only
Returns a Future that completes just before the window is about to repaint so the user can draw an animation frame. [...]
animationWorklet → _Worklet?
read-only
applicationCacheApplicationCache?
read-only
The application cache for this window. [...]
audioWorklet → _Worklet?
read-only
cachesCacheStorage?
read-only
closedbool?
read-only, override
Indicates whether this window has been closed. [...]
consoleConsole
read-only
The debugging console for this window.
cookieStoreCookieStore?
read-only
cryptoCrypto?
read-only
Entrypoint for the browser's cryptographic functions. [...]
customElementsCustomElementRegistry?
read-only
defaultStatusString?
read / write
Deprecated.
defaultstatusString?
read / write
Deprecated.
devicePixelRationum
read-only
The ratio between physical pixels and logical CSS pixels. [...]
documentDocument
read-only
The newest document in this window. [...]
externalExternal?
read-only
hashCodeint
read-only, inherited
The hash code for this object. [...]
historyHistory
read-only, override
The current session history for this window's newest document. [...]
indexedDBIdbFactory?
@SupportedBrowser(SupportedBrowser.CHROME, '23.0'), @SupportedBrowser(SupportedBrowser.FIREFOX, '15.0'), @SupportedBrowser(SupportedBrowser.IE, '10.0'), read-only
Gets an instance of the Indexed DB factory to being using Indexed DB. [...]
innerHeightint?
read-only
The height of the viewport including scrollbars. [...]
innerWidthint?
read-only
The width of the viewport including scrollbars. [...]
isSecureContextbool?
read-only
localStorageStorage
read-only
Storage for this window that persists across sessions. [...]
locationLocation
read / write, override-getter
The current location of this window. [...]
locationbarBarProp?
read-only
This window's location bar, which displays the URL. [...]
This window's menu bar, which displays menu commands. [...]
nameString?
read / write
The name of this window. [...]
The user agent accessing this window. [...]
offscreenBufferingbool?
read-only
Whether objects are drawn offscreen before being displayed. [...]
onEvents
read-only, inherited
This is an ease-of-use accessor for event streams which should only be used when an explicit accessor is not available.
onAbortStream<Event>
read-only, override
Stream of abort events handled by this Window.
onAnimationEndStream<AnimationEvent>
read-only
Stream of animationend events handled by this Window.
onAnimationIterationStream<AnimationEvent>
read-only
Stream of animationiteration events handled by this Window.
onAnimationStartStream<AnimationEvent>
read-only
Stream of animationstart events handled by this Window.
onBeforeUnloadStream<Event>
read-only
Stream of beforeunload events handled by this Window.
onBlurStream<Event>
read-only, override
Stream of blur events handled by this Window.
onCanPlayStream<Event>
read-only, override
onCanPlayThroughStream<Event>
read-only, override
onChangeStream<Event>
read-only, override
Stream of change events handled by this Window.
onClickStream<MouseEvent>
read-only, override
Stream of click events handled by this Window.
onContentLoadedStream<Event>
read-only
Stream of contentloaded events handled by this Window.
onContextMenuStream<MouseEvent>
read-only, override
Stream of contextmenu events handled by this Window.
onDeviceMotionStream<DeviceMotionEvent>
read-only
Stream of devicemotion events handled by this Window.
onDeviceOrientationStream<DeviceOrientationEvent>
read-only
Stream of deviceorientation events handled by this Window.
onDoubleClickStream<Event>
@DomName('Window.ondblclick'), read-only, override
Stream of doubleclick events handled by this Window.
onDragStream<MouseEvent>
read-only, override
Stream of drag events handled by this Window.
onDragEndStream<MouseEvent>
read-only, override
Stream of dragend events handled by this Window.
onDragEnterStream<MouseEvent>
read-only, override
Stream of dragenter events handled by this Window.
onDragLeaveStream<MouseEvent>
read-only, override
Stream of dragleave events handled by this Window.
onDragOverStream<MouseEvent>
read-only, override
Stream of dragover events handled by this Window.
onDragStartStream<MouseEvent>
read-only, override
Stream of dragstart events handled by this Window.
onDropStream<MouseEvent>
read-only, override
Stream of drop events handled by this Window.
onDurationChangeStream<Event>
read-only, override
onEmptiedStream<Event>
read-only, override
onEndedStream<Event>
read-only, override
onErrorStream<Event>
read-only, override
Stream of error events handled by this Window.
onFocusStream<Event>
read-only, override
Stream of focus events handled by this Window.
onHashChangeStream<Event>
read-only, override
Stream of hashchange events handled by this Window.
onInputStream<Event>
read-only, override
Stream of input events handled by this Window.
onInvalidStream<Event>
read-only, override
Stream of invalid events handled by this Window.
onKeyDownStream<KeyboardEvent>
read-only, override
Stream of keydown events handled by this Window.
onKeyPressStream<KeyboardEvent>
read-only, override
Stream of keypress events handled by this Window.
onKeyUpStream<KeyboardEvent>
read-only, override
Stream of keyup events handled by this Window.
onLoadStream<Event>
read-only, override
Stream of load events handled by this Window.
onLoadedDataStream<Event>
read-only, override
onLoadedMetadataStream<Event>
read-only, override
onLoadStartStream<Event>
read-only
onMessageStream<MessageEvent>
read-only, override
Stream of message events handled by this Window.
onMouseDownStream<MouseEvent>
read-only, override
Stream of mousedown events handled by this Window.
onMouseEnterStream<MouseEvent>
read-only, override
Stream of mouseenter events handled by this Window.
onMouseLeaveStream<MouseEvent>
read-only, override
Stream of mouseleave events handled by this Window.
onMouseMoveStream<MouseEvent>
read-only, override
Stream of mousemove events handled by this Window.
onMouseOutStream<MouseEvent>
read-only, override
Stream of mouseout events handled by this Window.
onMouseOverStream<MouseEvent>
read-only, override
Stream of mouseover events handled by this Window.
onMouseUpStream<MouseEvent>
read-only, override
Stream of mouseup events handled by this Window.
onMouseWheelStream<WheelEvent>
read-only, override
Stream of mousewheel events handled by this Window.
onOfflineStream<Event>
read-only, override
Stream of offline events handled by this Window.
onOnlineStream<Event>
read-only, override
Stream of online events handled by this Window.
onPageHideStream<Event>
read-only
Stream of pagehide events handled by this Window.
onPageShowStream<Event>
read-only
Stream of pageshow events handled by this Window.
onPauseStream<Event>
read-only, override
onPlayStream<Event>
read-only, override
onPlayingStream<Event>
read-only, override
onPopStateStream<PopStateEvent>
read-only, override
Stream of popstate events handled by this Window.
onProgressStream<Event>
read-only
onRateChangeStream<Event>
read-only, override
onResetStream<Event>
read-only, override
Stream of reset events handled by this Window.
onResizeStream<Event>
read-only, override
Stream of resize events handled by this Window.
onScrollStream<Event>
read-only, override
Stream of scroll events handled by this Window.
onSearchStream<Event>
read-only
Stream of search events handled by this Window.
onSeekedStream<Event>
read-only, override
onSeekingStream<Event>
read-only, override
onSelectStream<Event>
read-only, override
Stream of select events handled by this Window.
onStalledStream<Event>
read-only, override
onStorageStream<StorageEvent>
read-only, override
Stream of storage events handled by this Window.
onSubmitStream<Event>
read-only, override
Stream of submit events handled by this Window.
onSuspendStream<Event>
read-only, override
onTimeUpdateStream<Event>
read-only, override
onTouchCancelStream<TouchEvent>
read-only, override
Stream of touchcancel events handled by this Window.
onTouchEndStream<TouchEvent>
read-only, override
Stream of touchend events handled by this Window.
onTouchMoveStream<TouchEvent>
read-only, override
Stream of touchmove events handled by this Window.
onTouchStartStream<TouchEvent>
read-only, override
Stream of touchstart events handled by this Window.
onTransitionEndStream<TransitionEvent>
read-only
Stream of transitionend events handled by this Window.
onUnloadStream<Event>
read-only, override
Stream of unload events handled by this Window.
onVolumeChangeStream<Event>
read-only, override
onWaitingStream<Event>
read-only, override
onWheelStream<WheelEvent>
read-only, override
Stream of wheel events handled by this Window.
openerWindowBase?
read / write, override-getter
A reference to the window that opened this one. [...]
orientationint?
read-only
originString?
read-only
outerHeightint
read-only
The height of this window including all user interface elements. [...]
outerWidthint
read-only
The width of the window including all user interface elements. [...]
pageXOffsetint
read-only
pageYOffsetint
read-only
parentWindowBase?
read-only, override
A reference to the parent of this window. [...]
performancePerformance
@SupportedBrowser(SupportedBrowser.CHROME), @SupportedBrowser(SupportedBrowser.FIREFOX), @SupportedBrowser(SupportedBrowser.IE), read-only
Timing and navigation data for this window. [...]
runtimeTypeType
read-only, inherited
A representation of the runtime type of the object.
screenScreen?
read-only
Information about the screen displaying this window. [...]
screenLeftint?
read-only
The distance from the left side of the screen to the left side of this window. [...]
screenTopint?
read-only
The distance from the top of the screen to the top of this window. [...]
screenXint?
read-only
The distance from the left side of the screen to the mouse pointer. [...]
screenYint?
read-only
The distance from the top of the screen to the mouse pointer. [...]
scrollbarsBarProp?
read-only
This window's scroll bars. [...]
scrollXint
read-only
The distance this window has been scrolled horizontally. [...]
scrollYint
read-only
The distance this window has been scrolled vertically. [...]
selfWindowBase?
read-only
The current window. [...]
sessionStorageStorage
read-only
Storage for this window that is cleared when this session ends. [...]
speechSynthesisSpeechSynthesis?
read-only
Access to speech synthesis in the browser. [...]
statusString?
read / write
Deprecated.
statusbarBarProp?
read-only
This window's status bar. [...]
styleMediaStyleMedia?
read-only
Access to CSS media queries. [...]
toolbarBarProp?
read-only
This window's tool bar. [...]
topWindowBase?
read-only, override
A reference to the topmost window in the window hierarchy. [...]
visualViewportVisualViewport?
read-only
windowWindowBase?
read-only
The current window. [...]

Methods

addEventListener(String type, EventListener? listener, [bool? useCapture]) → void
inherited
alert([String? message]) → void
Displays a modal alert to the user. [...]
atob(String atob) → String
override
btoa(String btoa) → String
override
cancelAnimationFrame(int id) → void
Cancels an animation frame request. [...]
cancelIdleCallback(int handle) → void
close() → void
override
Closes the window. [...]
confirm([String? message]) → bool
Displays a modal OK/Cancel prompt to the user. [...]
dispatchEvent(Event event) → bool
inherited
fetch(dynamic input, [Map? init]) → Future
find(String? string, bool? caseSensitive, bool? backwards, bool? wrap, bool? wholeWord, bool? searchInFrames, bool? showDialog) → bool
Finds text in this window. [...]
getComputedStyleMap(Element element, String? pseudoElement) → StylePropertyMapReadonly
getMatchedCssRules(Element? element, String? pseudoElement) → List<CssRule>
@Creates('_CssRuleList'), @JSName('getMatchedCSSRules'), @Returns('_CssRuleList')
Returns all CSS rules that apply to the element's pseudo-element.
getSelection() → Selection?
Returns the currently selected text. [...]
matchMedia(String query) → MediaQueryList
Returns a list of media queries for the given query string. [...]
moveBy(int x, int y) → void
Moves this window. [...]
moveTo(Point<num> p) → void
Moves this window to a specific position. [...]
noSuchMethod(Invocation invocation) → dynamic
inherited
Invoked when a non-existent method or property is accessed. [...]
open(String url, String name, [String? options]) → WindowBase
Opens a new window. [...]
openDatabase(String name, String version, String displayName, int estimatedSize, [DatabaseCallback? creationCallback]) → SqlDatabase
@Creates('SqlDatabase'), @JSName('openDatabase'), @SupportedBrowser(SupportedBrowser.CHROME), @SupportedBrowser(SupportedBrowser.SAFARI)
postMessage(dynamic message, String targetOrigin, [List<Object>? transfer]) → void
override
Sends a cross-origin message. [...]
print() → void
Opens the print dialog for this window. [...]
removeEventListener(String type, EventListener? listener, [bool? useCapture]) → void
inherited
requestAnimationFrame(FrameRequestCallback callback) → int
Called to draw an animation frame and then request the window to repaint after callback has finished (creating the animation). [...]
requestFileSystem(int size, {bool persistent = false}) → Future<FileSystem>
Access a sandboxed file system of size bytes. [...]
requestIdleCallback(IdleRequestCallback callback, [Map? options]) → int
resizeBy(int x, int y) → void
Resizes this window by an offset. [...]
resizeTo(int x, int y) → void
Resizes this window to a specific width and height. [...]
resolveLocalFileSystemUrl(String url) → Future<Entry>
@JSName('webkitResolveLocalFileSystemURL'), @SupportedBrowser(SupportedBrowser.CHROME)
Asynchronously retrieves a local filesystem entry. [...]
scroll([dynamic options_OR_x, dynamic y, Map? scrollOptions]) → void
Scrolls the page horizontally and vertically to a specific point. [...]
scrollBy([dynamic options_OR_x, dynamic y, Map? scrollOptions]) → void
Scrolls the page horizontally and vertically by an offset. [...]
scrollTo([dynamic options_OR_x, dynamic y, Map? scrollOptions]) → void
Scrolls the page horizontally and vertically to a specific point. [...]
stop() → void
Stops the window from loading. [...]
toString() → String
inherited
A string representation of this object. [...]

Operators

operator ==(Object other) → bool
inherited
The equality operator. [...]

Static Properties

supportsPointConversionsbool
read-only
convertPointFromNodeToPage and convertPointFromPageToNode are removed. see http://dev.w3.org/csswg/cssom-view/#geometry

Constants

animationEndEvent → const EventStreamProvider<AnimationEvent>
@SupportedBrowser(SupportedBrowser.CHROME), @SupportedBrowser(SupportedBrowser.SAFARI)
Static factory designed to expose animationend events to event handlers that are not necessarily instances of Window. [...]
const EventStreamProvider<AnimationEvent>('webkitAnimationEnd')
animationIterationEvent → const EventStreamProvider<AnimationEvent>
@SupportedBrowser(SupportedBrowser.CHROME), @SupportedBrowser(SupportedBrowser.SAFARI)
Static factory designed to expose animationiteration events to event handlers that are not necessarily instances of Window. [...]
const EventStreamProvider<AnimationEvent>('webkitAnimationIteration')
animationStartEvent → const EventStreamProvider<AnimationEvent>
@SupportedBrowser(SupportedBrowser.CHROME), @SupportedBrowser(SupportedBrowser.SAFARI)
Static factory designed to expose animationstart events to event handlers that are not necessarily instances of Window. [...]
const EventStreamProvider<AnimationEvent>('webkitAnimationStart')
beforeUnloadEvent → const EventStreamProvider<BeforeUnloadEvent>
Static factory designed to expose beforeunload events to event handlers that are not necessarily instances of Window. [...]
const _BeforeUnloadEventStreamProvider('beforeunload')
contentLoadedEvent → const EventStreamProvider<Event>
Static factory designed to expose contentloaded events to event handlers that are not necessarily instances of Window. [...]
const EventStreamProvider<Event>('DOMContentLoaded')
deviceMotionEvent → const EventStreamProvider<DeviceMotionEvent>
Static factory designed to expose devicemotion events to event handlers that are not necessarily instances of Window. [...]
const EventStreamProvider<DeviceMotionEvent>('devicemotion')
deviceOrientationEvent → const EventStreamProvider<DeviceOrientationEvent>
Static factory designed to expose deviceorientation events to event handlers that are not necessarily instances of Window. [...]
const EventStreamProvider<DeviceOrientationEvent>('deviceorientation')
hashChangeEvent → const EventStreamProvider<Event>
Static factory designed to expose hashchange events to event handlers that are not necessarily instances of Window. [...]
const EventStreamProvider<Event>('hashchange')
loadStartEvent → const EventStreamProvider<Event>
const EventStreamProvider<Event>('loadstart')
messageEvent → const EventStreamProvider<MessageEvent>
Static factory designed to expose message events to event handlers that are not necessarily instances of Window. [...]
const EventStreamProvider<MessageEvent>('message')
offlineEvent → const EventStreamProvider<Event>
Static factory designed to expose offline events to event handlers that are not necessarily instances of Window. [...]
const EventStreamProvider<Event>('offline')
onlineEvent → const EventStreamProvider<Event>
Static factory designed to expose online events to event handlers that are not necessarily instances of Window. [...]
const EventStreamProvider<Event>('online')
pageHideEvent → const EventStreamProvider<Event>
Static factory designed to expose pagehide events to event handlers that are not necessarily instances of Window. [...]
const EventStreamProvider<Event>('pagehide')
pageShowEvent → const EventStreamProvider<Event>
Static factory designed to expose pageshow events to event handlers that are not necessarily instances of Window. [...]
const EventStreamProvider<Event>('pageshow')
PERSISTENT → const int
Indicates that file system data cannot be cleared unless given user permission. [...]
1
popStateEvent → const EventStreamProvider<PopStateEvent>
Static factory designed to expose popstate events to event handlers that are not necessarily instances of Window. [...]
const EventStreamProvider<PopStateEvent>('popstate')
progressEvent → const EventStreamProvider<Event>
const EventStreamProvider<Event>('progress')
storageEvent → const EventStreamProvider<StorageEvent>
Static factory designed to expose storage events to event handlers that are not necessarily instances of Window. [...]
const EventStreamProvider<StorageEvent>('storage')
TEMPORARY → const int
Indicates that file system data can be cleared at any time. [...]
0
unloadEvent → const EventStreamProvider<Event>
Static factory designed to expose unload events to event handlers that are not necessarily instances of Window. [...]
const EventStreamProvider<Event>('unload')

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.13.0/dart-html/Window-class.html