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
- DOM Window from MDN.
- Window from the W3C.
- Inheritance
- Object
- EventTarget
- Window
- Implemented types
- Annotations
- @Native("Window,DOMWindow")
Properties
-
animationFrame
→ Future<
num> -
Returns a Future that completes just before the window is about to
repaint so the user can draw an animation frame. [...]
read-only
- animationWorklet → _Worklet
-
final
- applicationCache → ApplicationCache
-
The application cache for this window. [...]
final
- audioWorklet → _Worklet
-
final
- caches → CacheStorage
-
final
- closed → bool
-
Indicates whether this window has been closed. [...]
final
- console → Console
-
The debugging console for this window.
read-only
-
final
- crypto → Crypto
-
Entrypoint for the browser's cryptographic functions. [...]
final
- customElements → CustomElementRegistry
-
final
- defaultStatus ↔ String
-
Deprecated.
read / write
- defaultstatus ↔ String
-
Deprecated.
read / write
- devicePixelRatio → num
-
The ratio between physical pixels and logical CSS pixels. [...]
final
- document → Document
-
The newest document in this window. [...]
read-only
- external → External
-
final
- history → History
-
The current session history for this window's newest document. [...]
final
- indexedDB → IdbFactory
-
Gets an instance of the Indexed DB factory to being using Indexed DB. [...]
@SupportedBrowser(SupportedBrowser.CHROME, '23.0'), @SupportedBrowser(SupportedBrowser.FIREFOX, '15.0'), @SupportedBrowser(SupportedBrowser.IE, '10.0'), read-only
- innerHeight → int
-
The height of the viewport including scrollbars. [...]
final
- innerWidth → int
-
The width of the viewport including scrollbars. [...]
final
- isSecureContext → bool
-
final
- localStorage → Storage
-
Storage for this window that persists across sessions. [...]
final
- location ↔ Location
-
The current location of this window. [...]
read / write, override-getter
- locationbar → BarProp
-
This window's location bar, which displays the URL. [...]
final
-
This window's menu bar, which displays menu commands. [...]
final
- name ↔ String
-
The name of this window. [...]
read / write
-
The user agent accessing this window. [...]
final
- offscreenBuffering → bool
-
Whether objects are drawn offscreen before being displayed. [...]
final
-
onAbort
→ Stream<
Event> -
Stream of
abort
events handled by this Window.read-only, override -
onAnimationEnd
→ Stream<
AnimationEvent> -
Stream of
animationend
events handled by this Window.read-only -
onAnimationIteration
→ Stream<
AnimationEvent> -
Stream of
animationiteration
events handled by this Window.read-only -
onAnimationStart
→ Stream<
AnimationEvent> -
Stream of
animationstart
events handled by this Window.read-only -
onBeforeUnload
→ Stream<
Event> -
Stream of
beforeunload
events handled by this Window.read-only -
onBlur
→ Stream<
Event> -
Stream of
blur
events handled by this Window.read-only, override -
onCanPlay
→ Stream<
Event> -
read-only, override
-
onCanPlayThrough
→ Stream<
Event> -
read-only, override
-
onChange
→ Stream<
Event> -
Stream of
change
events handled by this Window.read-only, override -
onClick
→ Stream<
MouseEvent> -
Stream of
click
events handled by this Window.read-only, override -
onContentLoaded
→ Stream<
Event> -
Stream of
contentloaded
events handled by this Window.read-only -
onContextMenu
→ Stream<
MouseEvent> -
Stream of
contextmenu
events handled by this Window.read-only, override -
onDeviceMotion
→ Stream<
DeviceMotionEvent> -
Stream of
devicemotion
events handled by this Window.read-only -
onDeviceOrientation
→ Stream<
DeviceOrientationEvent> -
Stream of
deviceorientation
events handled by this Window.read-only -
onDoubleClick
→ Stream<
Event> -
Stream of
doubleclick
events handled by this Window.@DomName('Window.ondblclick'), read-only, override -
onDrag
→ Stream<
MouseEvent> -
Stream of
drag
events handled by this Window.read-only, override -
onDragEnd
→ Stream<
MouseEvent> -
Stream of
dragend
events handled by this Window.read-only, override -
onDragEnter
→ Stream<
MouseEvent> -
Stream of
dragenter
events handled by this Window.read-only, override -
onDragLeave
→ Stream<
MouseEvent> -
Stream of
dragleave
events handled by this Window.read-only, override -
onDragOver
→ Stream<
MouseEvent> -
Stream of
dragover
events handled by this Window.read-only, override -
onDragStart
→ Stream<
MouseEvent> -
Stream of
dragstart
events handled by this Window.read-only, override -
onDrop
→ Stream<
MouseEvent> -
Stream of
drop
events handled by this Window.read-only, override -
onDurationChange
→ Stream<
Event> -
read-only, override
-
onEmptied
→ Stream<
Event> -
read-only, override
-
onEnded
→ Stream<
Event> -
read-only, override
-
onError
→ Stream<
Event> -
Stream of
error
events handled by this Window.read-only, override -
onFocus
→ Stream<
Event> -
Stream of
focus
events handled by this Window.read-only, override -
onHashChange
→ Stream<
Event> -
Stream of
hashchange
events handled by this Window.read-only, override -
onInput
→ Stream<
Event> -
Stream of
input
events handled by this Window.read-only, override -
onInvalid
→ Stream<
Event> -
Stream of
invalid
events handled by this Window.read-only, override -
onKeyDown
→ Stream<
KeyboardEvent> -
Stream of
keydown
events handled by this Window.read-only, override -
onKeyPress
→ Stream<
KeyboardEvent> -
Stream of
keypress
events handled by this Window.read-only, override -
onKeyUp
→ Stream<
KeyboardEvent> -
Stream of
keyup
events handled by this Window.read-only, override -
onLoad
→ Stream<
Event> -
Stream of
load
events handled by this Window.read-only, override -
onLoadedData
→ Stream<
Event> -
read-only, override
-
onLoadedMetadata
→ Stream<
Event> -
read-only, override
-
onLoadStart
→ Stream<
Event> -
read-only
-
onMessage
→ Stream<
MessageEvent> -
Stream of
message
events handled by this Window.read-only, override -
onMouseDown
→ Stream<
MouseEvent> -
Stream of
mousedown
events handled by this Window.read-only, override -
onMouseEnter
→ Stream<
MouseEvent> -
Stream of
mouseenter
events handled by this Window.read-only, override -
onMouseLeave
→ Stream<
MouseEvent> -
Stream of
mouseleave
events handled by this Window.read-only, override -
onMouseMove
→ Stream<
MouseEvent> -
Stream of
mousemove
events handled by this Window.read-only, override -
onMouseOut
→ Stream<
MouseEvent> -
Stream of
mouseout
events handled by this Window.read-only, override -
onMouseOver
→ Stream<
MouseEvent> -
Stream of
mouseover
events handled by this Window.read-only, override -
onMouseUp
→ Stream<
MouseEvent> -
Stream of
mouseup
events handled by this Window.read-only, override -
onMouseWheel
→ Stream<
WheelEvent> -
Stream of
mousewheel
events handled by this Window.read-only, override -
onOffline
→ Stream<
Event> -
Stream of
offline
events handled by this Window.read-only, override -
onOnline
→ Stream<
Event> -
Stream of
online
events handled by this Window.read-only, override -
onPageHide
→ Stream<
Event> -
Stream of
pagehide
events handled by this Window.read-only -
onPageShow
→ Stream<
Event> -
Stream of
pageshow
events handled by this Window.read-only -
onPause
→ Stream<
Event> -
read-only, override
-
onPlay
→ Stream<
Event> -
read-only, override
-
onPlaying
→ Stream<
Event> -
read-only, override
-
onPopState
→ Stream<
PopStateEvent> -
Stream of
popstate
events handled by this Window.read-only, override -
onProgress
→ Stream<
Event> -
read-only
-
onRateChange
→ Stream<
Event> -
read-only, override
-
onReset
→ Stream<
Event> -
Stream of
reset
events handled by this Window.read-only, override -
onResize
→ Stream<
Event> -
Stream of
resize
events handled by this Window.read-only, override -
onScroll
→ Stream<
Event> -
Stream of
scroll
events handled by this Window.read-only, override -
onSearch
→ Stream<
Event> -
Stream of
search
events handled by this Window.read-only -
onSeeked
→ Stream<
Event> -
read-only, override
-
onSeeking
→ Stream<
Event> -
read-only, override
-
onSelect
→ Stream<
Event> -
Stream of
select
events handled by this Window.read-only, override -
onStalled
→ Stream<
Event> -
read-only, override
-
onStorage
→ Stream<
StorageEvent> -
Stream of
storage
events handled by this Window.read-only, override -
onSubmit
→ Stream<
Event> -
Stream of
submit
events handled by this Window.read-only, override -
onSuspend
→ Stream<
Event> -
read-only, override
-
onTimeUpdate
→ Stream<
Event> -
read-only, override
-
onTouchCancel
→ Stream<
TouchEvent> -
Stream of
touchcancel
events handled by this Window.read-only, override -
onTouchEnd
→ Stream<
TouchEvent> -
Stream of
touchend
events handled by this Window.read-only, override -
onTouchMove
→ Stream<
TouchEvent> -
Stream of
touchmove
events handled by this Window.read-only, override -
onTouchStart
→ Stream<
TouchEvent> -
Stream of
touchstart
events handled by this Window.read-only, override -
onTransitionEnd
→ Stream<
TransitionEvent> -
Stream of
transitionend
events handled by this Window.read-only -
onUnload
→ Stream<
Event> -
Stream of
unload
events handled by this Window.read-only, override -
onVolumeChange
→ Stream<
Event> -
read-only, override
-
onWaiting
→ Stream<
Event> -
read-only, override
-
onWheel
→ Stream<
WheelEvent> -
Stream of
wheel
events handled by this Window.read-only, override - opener ↔ WindowBase
-
A reference to the window that opened this one. [...]
read / write, override-getter
- orientation → int
-
final
- origin → String
-
final
- outerHeight → int
-
The height of this window including all user interface elements. [...]
final
- outerWidth → int
-
The width of the window including all user interface elements. [...]
final
- pageXOffset → int
-
read-only
- pageYOffset → int
-
read-only
- parent → WindowBase
-
A reference to the parent of this window. [...]
read-only, override
- performance → Performance
-
Timing and navigation data for this window. [...]
@SupportedBrowser(SupportedBrowser.CHROME), @SupportedBrowser(SupportedBrowser.FIREFOX), @SupportedBrowser(SupportedBrowser.IE), final
- screen → Screen
-
Information about the screen displaying this window. [...]
final
- screenLeft → int
-
The distance from the left side of the screen to the left side of this
window. [...]
final
- screenTop → int
-
The distance from the top of the screen to the top of this window. [...]
final
- screenX → int
-
The distance from the left side of the screen to the mouse pointer. [...]
final
- screenY → int
-
The distance from the top of the screen to the mouse pointer. [...]
final
- scrollbars → BarProp
-
This window's scroll bars. [...]
final
- scrollX → int
-
The distance this window has been scrolled horizontally. [...]
read-only
- scrollY → int
-
The distance this window has been scrolled vertically. [...]
read-only
- self → WindowBase
-
The current window. [...]
read-only
- sessionStorage → Storage
-
Storage for this window that is cleared when this session ends. [...]
final
- speechSynthesis → SpeechSynthesis
-
Access to speech synthesis in the browser. [...]
final
- status ↔ String
-
Deprecated.
read / write
- statusbar → BarProp
-
This window's status bar. [...]
final
- styleMedia → StyleMedia
-
Access to CSS media queries. [...]
final
- toolbar → BarProp
-
This window's tool bar. [...]
final
- top → WindowBase
-
A reference to the topmost window in the window hierarchy. [...]
read-only, override
- visualViewport → VisualViewport
-
final
- window → WindowBase
-
The current window. [...]
read-only
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- on → Events
-
This is an ease-of-use accessor for event streams which should only be
used when an explicit accessor is not available.
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
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 -
Closes the window. [...]
override
-
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> -
Returns all CSS rules that apply to the element's pseudo-element.
@Creates('_CssRuleList'), @JSName('getMatchedCSSRules'), @Returns('_CssRuleList|Null')
-
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 -
Sends a cross-origin message. [...]
override
-
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> -
Asynchronously retrieves a local filesystem entry. [...]
@JSName('webkitResolveLocalFileSystemURL'), @SupportedBrowser(SupportedBrowser.CHROME)
-
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 -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
removeEventListener(
String type, EventListener listener, [ bool useCapture ]) → void -
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited
Static Properties
- supportsPointConversions → bool
-
convertPointFromNodeToPage and convertPointFromPageToNode are removed.
see http://dev.w3.org/csswg/cssom-view/#geometry
read-only
Constants
-
animationEndEvent
→ const EventStreamProvider<
AnimationEvent> -
Static factory designed to expose
animationend
events to event handlers that are not necessarily instances of Window. [...]@SupportedBrowser(SupportedBrowser.CHROME), @SupportedBrowser(SupportedBrowser.SAFARI)const EventStreamProvider<AnimationEvent>('webkitAnimationEnd')
-
animationIterationEvent
→ const EventStreamProvider<
AnimationEvent> -
Static factory designed to expose
animationiteration
events to event handlers that are not necessarily instances of Window. [...]@SupportedBrowser(SupportedBrowser.CHROME), @SupportedBrowser(SupportedBrowser.SAFARI)const EventStreamProvider<AnimationEvent>('webkitAnimationIteration')
-
animationStartEvent
→ const EventStreamProvider<
AnimationEvent> -
Static factory designed to expose
animationstart
events to event handlers that are not necessarily instances of Window. [...]@SupportedBrowser(SupportedBrowser.CHROME), @SupportedBrowser(SupportedBrowser.SAFARI)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')