dart:html
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
- animationFrame → Future<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
- applicationCache → ApplicationCache?
read-only
- The application cache for this window.
- audioWorklet → _Worklet?
read-only
- caches → CacheStorage?
read-only
- closed → bool?
read-only, override
- Indicates whether this window has been closed.
- console → Console
read-only
- The debugging console for this window.
- cookieStore → CookieStore?
read-only
- crypto → Crypto?
read-only
- Entrypoint for the browser's cryptographic functions.
- customElements → CustomElementRegistry?
read-only
- defaultStatus ↔ String?
read / write
- Deprecated.
- defaultstatus ↔ String?
read / write
- Deprecated.
- devicePixelRatio → num
read-only
- The ratio between physical pixels and logical CSS pixels.
- document → Document
read-only
- The newest document in this window.
- external → External?
read-only
- hashCode → int
read-only, inherited
- The hash code for this object.
- history → History
read-only, override
- The current session history for this window's newest document.
- indexedDB → IdbFactory?
@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.
- innerHeight → int?
read-only
- The height of the viewport including scrollbars.
- innerWidth → int?
read-only
- The width of the viewport including scrollbars.
- isSecureContext → bool?
read-only
- localStorage → Storage
read-only
- Storage for this window that persists across sessions.
- location ↔ Location
read / write, override-getter
- The current location of this window.
- locationbar → BarProp?
read-only
- This window's location bar, which displays the URL.
- This window's menu bar, which displays menu commands.
- name ↔ String?
read / write
- The name of this window.
- navigator → Navigator
read-only
- The user agent accessing this window.
- offscreenBuffering → bool?
read-only
- Whether objects are drawn offscreen before being displayed.
- on → Events
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.
- onAbort → Stream<Event>
read-only, override
- Stream of
abort events handled by this Window. - onAnimationEnd → Stream<AnimationEvent>
read-only
- Stream of
animationend events handled by this Window. - onAnimationIteration → Stream<AnimationEvent>
read-only
- Stream of
animationiteration events handled by this Window. - onAnimationStart → Stream<AnimationEvent>
read-only
- Stream of
animationstart events handled by this Window. - onBeforeUnload → Stream<Event>
read-only
- Stream of
beforeunload events handled by this Window. - onBlur → Stream<Event>
read-only, override
- Stream of
blur events handled by this Window. - onCanPlay → Stream<Event>
read-only, override
- onCanPlayThrough → Stream<Event>
read-only, override
- onChange → Stream<Event>
read-only, override
- Stream of
change events handled by this Window. - onClick → Stream<MouseEvent>
read-only, override
- Stream of
click events handled by this Window. - onContentLoaded → Stream<Event>
read-only
- Stream of
contentloaded events handled by this Window. - Stream of
contextmenu events handled by this Window. - onDeviceMotion → Stream<DeviceMotionEvent>
read-only
- Stream of
devicemotion events handled by this Window. - onDeviceOrientation → Stream<DeviceOrientationEvent>
read-only
- Stream of
deviceorientation events handled by this Window. - onDoubleClick → Stream<Event>
@DomName('Window.ondblclick'), read-only, override
- Stream of
doubleclick events handled by this Window. - onDrag → Stream<MouseEvent>
read-only, override
- Stream of
drag events handled by this Window. - onDragEnd → Stream<MouseEvent>
read-only, override
- Stream of
dragend events handled by this Window. - onDragEnter → Stream<MouseEvent>
read-only, override
- Stream of
dragenter events handled by this Window. - onDragLeave → Stream<MouseEvent>
read-only, override
- Stream of
dragleave events handled by this Window. - onDragOver → Stream<MouseEvent>
read-only, override
- Stream of
dragover events handled by this Window. - onDragStart → Stream<MouseEvent>
read-only, override
- Stream of
dragstart events handled by this Window. - onDrop → Stream<MouseEvent>
read-only, override
- Stream of
drop events handled by this Window. - onDurationChange → Stream<Event>
read-only, override
- onEmptied → Stream<Event>
read-only, override
- onEnded → Stream<Event>
read-only, override
- onError → Stream<Event>
read-only, override
- Stream of
error events handled by this Window. - onFocus → Stream<Event>
read-only, override
- Stream of
focus events handled by this Window. - onHashChange → Stream<Event>
read-only, override
- Stream of
hashchange events handled by this Window. - onInput → Stream<Event>
read-only, override
- Stream of
input events handled by this Window. - onInvalid → Stream<Event>
read-only, override
- Stream of
invalid events handled by this Window. - onKeyDown → Stream<KeyboardEvent>
read-only, override
- Stream of
keydown events handled by this Window. - onKeyPress → Stream<KeyboardEvent>
read-only, override
- Stream of
keypress events handled by this Window. - onKeyUp → Stream<KeyboardEvent>
read-only, override
- Stream of
keyup events handled by this Window. - onLoad → Stream<Event>
read-only, override
- Stream of
load events handled by this Window. - onLoadedData → Stream<Event>
read-only, override
- onLoadedMetadata → Stream<Event>
read-only, override
- onLoadStart → Stream<Event>
read-only
- onMessage → Stream<MessageEvent>
read-only, override
- Stream of
message events handled by this Window. - onMouseDown → Stream<MouseEvent>
read-only, override
- Stream of
mousedown events handled by this Window. - onMouseEnter → Stream<MouseEvent>
read-only, override
- Stream of
mouseenter events handled by this Window. - onMouseLeave → Stream<MouseEvent>
read-only, override
- Stream of
mouseleave events handled by this Window. - onMouseMove → Stream<MouseEvent>
read-only, override
- Stream of
mousemove events handled by this Window. - onMouseOut → Stream<MouseEvent>
read-only, override
- Stream of
mouseout events handled by this Window. - onMouseOver → Stream<MouseEvent>
read-only, override
- Stream of
mouseover events handled by this Window. - onMouseUp → Stream<MouseEvent>
read-only, override
- Stream of
mouseup events handled by this Window. - onMouseWheel → Stream<WheelEvent>
read-only, override
- Stream of
mousewheel events handled by this Window. - onOffline → Stream<Event>
read-only, override
- Stream of
offline events handled by this Window. - onOnline → Stream<Event>
read-only, override
- Stream of
online events handled by this Window. - onPageHide → Stream<Event>
read-only
- Stream of
pagehide events handled by this Window. - onPageShow → Stream<Event>
read-only
- Stream of
pageshow events handled by this Window. - onPause → Stream<Event>
read-only, override
- onPlay → Stream<Event>
read-only, override
- onPlaying → Stream<Event>
read-only, override
- onPopState → Stream<PopStateEvent>
read-only, override
- Stream of
popstate events handled by this Window. - onProgress → Stream<Event>
read-only
- onRateChange → Stream<Event>
read-only, override
- onReset → Stream<Event>
read-only, override
- Stream of
reset events handled by this Window. - onResize → Stream<Event>
read-only, override
- Stream of
resize events handled by this Window. - onScroll → Stream<Event>
read-only, override
- Stream of
scroll events handled by this Window. - onSearch → Stream<Event>
read-only
- Stream of
search events handled by this Window. - onSeeked → Stream<Event>
read-only, override
- onSeeking → Stream<Event>
read-only, override
- onSelect → Stream<Event>
read-only, override
- Stream of
select events handled by this Window. - onStalled → Stream<Event>
read-only, override
- onStorage → Stream<StorageEvent>
read-only, override
- Stream of
storage events handled by this Window. - onSubmit → Stream<Event>
read-only, override
- Stream of
submit events handled by this Window. - onSuspend → Stream<Event>
read-only, override
- onTimeUpdate → Stream<Event>
read-only, override
- onTouchCancel → Stream<TouchEvent>
read-only, override
- Stream of
touchcancel events handled by this Window. - onTouchEnd → Stream<TouchEvent>
read-only, override
- Stream of
touchend events handled by this Window. - onTouchMove → Stream<TouchEvent>
read-only, override
- Stream of
touchmove events handled by this Window. - onTouchStart → Stream<TouchEvent>
read-only, override
- Stream of
touchstart events handled by this Window. - onTransitionEnd → Stream<TransitionEvent>
read-only
- Stream of
transitionend events handled by this Window. - onUnload → Stream<Event>
read-only, override
- Stream of
unload events handled by this Window. - onVolumeChange → Stream<Event>
read-only, override
- onWaiting → Stream<Event>
read-only, override
- onWheel → Stream<WheelEvent>
read-only, override
- Stream of
wheel events handled by this Window. - opener ↔ WindowBase?
read / write, override-getter
- A reference to the window that opened this one.
- orientation → int?
read-only
- origin → String?
read-only
- outerHeight → int
read-only
- The height of this window including all user interface elements.
- outerWidth → int
read-only
- The width of the window including all user interface elements.
- pageXOffset → int
read-only
- pageYOffset → int
read-only
- parent → WindowBase?
read-only, override
- A reference to the parent of this window.
- performance → Performance
@SupportedBrowser(SupportedBrowser.CHROME), @SupportedBrowser(SupportedBrowser.FIREFOX), @SupportedBrowser(SupportedBrowser.IE), read-only
- Timing and navigation data for this window.
- runtimeType → Type
read-only, inherited
- A representation of the runtime type of the object.
- screen → Screen?
read-only
- Information about the screen displaying this window.
- screenLeft → int?
read-only
- The distance from the left side of the screen to the left side of this window.
- screenTop → int?
read-only
- The distance from the top of the screen to the top of this window.
- screenX → int?
read-only
- The distance from the left side of the screen to the mouse pointer.
- screenY → int?
read-only
- The distance from the top of the screen to the mouse pointer.
- scrollbars → BarProp?
read-only
- This window's scroll bars.
- scrollX → int
read-only
- The distance this window has been scrolled horizontally.
- scrollY → int
read-only
- The distance this window has been scrolled vertically.
- self → WindowBase?
read-only
- The current window.
- sessionStorage → Storage
read-only
- Storage for this window that is cleared when this session ends.
- speechSynthesis → SpeechSynthesis?
read-only
- Access to speech synthesis in the browser.
- status ↔ String?
read / write
- Deprecated.
- statusbar → BarProp?
read-only
- This window's status bar.
- styleMedia → StyleMedia?
read-only
- Access to CSS media queries.
- toolbar → BarProp?
read-only
- This window's tool bar.
- top → WindowBase?
read-only, override
- A reference to the topmost window in the window hierarchy.
- visualViewport → VisualViewport?
read-only
- window → WindowBase?
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>
@JSName('getMatchedCSSRules'), @Returns('_CssRuleList'), @Creates('_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.
- 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
- supportsPointConversions → bool
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. - 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')