W3cubDocs

/Dart 2

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
final
applicationCacheApplicationCache
final
The application cache for this window. [...]
audioWorklet → _Worklet
final
cachesCacheStorage
final
closedbool
final
Indicates whether this window has been closed. [...]
consoleConsole
read-only
The debugging console for this window.
cookieStoreCookieStore
final
cryptoCrypto
final
Entrypoint for the browser's cryptographic functions. [...]
customElementsCustomElementRegistry
final
defaultStatusString
read / write
Deprecated.
defaultstatusString
read / write
Deprecated.
devicePixelRationum
final
The ratio between physical pixels and logical CSS pixels. [...]
documentDocument
read-only
The newest document in this window. [...]
externalExternal
final
historyHistory
final
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
final
The height of the viewport including scrollbars. [...]
innerWidthint
final
The width of the viewport including scrollbars. [...]
isSecureContextbool
final
localStorageStorage
final
Storage for this window that persists across sessions. [...]
locationLocation
read / write, override-getter
The current location of this window. [...]
locationbarBarProp
final
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
final
Whether objects are drawn offscreen before being displayed. [...]
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
final
originString
final
outerHeightint
final
The height of this window including all user interface elements. [...]
outerWidthint
final
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), final
Timing and navigation data for this window. [...]
screenScreen
final
Information about the screen displaying this window. [...]
screenLeftint
final
The distance from the left side of the screen to the left side of this window. [...]
screenTopint
final
The distance from the top of the screen to the top of this window. [...]
screenXint
final
The distance from the left side of the screen to the mouse pointer. [...]
screenYint
final
The distance from the top of the screen to the mouse pointer. [...]
scrollbarsBarProp
final
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
final
Storage for this window that is cleared when this session ends. [...]
speechSynthesisSpeechSynthesis
final
Access to speech synthesis in the browser. [...]
statusString
read / write
Deprecated.
statusbarBarProp
final
This window's status bar. [...]
styleMediaStyleMedia
final
Access to CSS media queries. [...]
toolbarBarProp
final
This window's tool bar. [...]
topWindowBase
read-only, override
A reference to the topmost window in the window hierarchy. [...]
visualViewportVisualViewport
final
windowWindowBase
read-only
The current window. [...]
hashCodeint
read-only, inherited
The hash code for this object. [...]
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.
runtimeTypeType
read-only, inherited
A representation of the runtime type of the object.

Methods

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. [...]
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|Null')
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. [...]
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. [...]
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. [...]
addEventListener(String type, EventListener listener, [ bool useCapture ]) → void
inherited
dispatchEvent(Event event) → bool
inherited
noSuchMethod(Invocation invocation) → dynamic
inherited
Invoked when a non-existent method or property is accessed. [...]
removeEventListener(String type, EventListener listener, [ bool useCapture ]) → void
inherited
toString() → String
inherited
Returns a string representation of this object.

Operators

operator ==(dynamic 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.5.0/dart-html/Window-class.html