Window#
Annotations: @Native.new("Window,DOMWindow")
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
Properties#
animationFrame no setter#
Returns a Future that completes just before the window is about to repaint so the user can draw an animation frame.
If you need to later cancel this animation, use requestAnimationFrame instead.
The Future completes to a timestamp that represents a floating point value of the number of milliseconds that have elapsed since the page started to load (which is also the timestamp at this call to animationFrame).
Note: The code that runs when the future completes should call animationFrame again for the animation to continue.
Implementation
Future<num> get animationFrame {
var completer = new Completer<num>.sync();
requestAnimationFrame((time) {
completer.complete(time);
});
return completer.future;
}
animationWorklet no setter#
Implementation
_Worklet? get animationWorklet native;
applicationCache no setter#
The application cache for this window.
Other resources
- A beginner's guide to using the application cache from HTML5Rocks.
- Application cache API from WHATWG.
Implementation
ApplicationCache? get applicationCache native;
audioWorklet no setter#
Implementation
_Worklet? get audioWorklet native;
caches no setter#
Implementation
CacheStorage? get caches native;
closed no setter override#
Indicates whether this window has been closed.
print(window.closed); // 'false'
window.close();
print(window.closed); // 'true'
MDN does not have compatibility info on this attribute, and therefore is marked nullable.
Implementation
bool? get closed native;
console no setter#
The debugging console for this window.
Implementation
Console get console => Console._safeConsole;
cookieStore no setter#
Implementation
CookieStore? get cookieStore native;
crypto no setter#
Entrypoint for the browser's cryptographic functions.
Other resources
- Web cryptography API from W3C.
Implementation
Crypto? get crypto native;
customElements no setter#
Implementation
CustomElementRegistry? get customElements native;
defaultStatus read / write#
Deprecated.
Implementation
String? get defaultStatus native;
set defaultStatus(String? value) native;
defaultstatus read / write#
Deprecated.
Implementation
String? get defaultstatus native;
set defaultstatus(String? value) native;
devicePixelRatio no setter#
The ratio between physical pixels and logical CSS pixels.
Other resources
- devicePixelRatio from quirksmode.
- More about devicePixelRatio from quirksmode.
Implementation
num get devicePixelRatio native;
document no setter#
The newest document in this window.
Other resources
- Loading web pages from WHATWG.
Implementation
Document get document => JS('Document', '#.document', this);
external no setter#
Implementation
External? get external native;
hashCode no setter inherited#
Inherited from Interceptor.
Implementation
int get hashCode => Primitives.objectHashCode(this);
history no setter override#
The current session history for this window's newest document.
Other resources
- Loading web pages from WHATWG.
Implementation
History get history native;
indexedDB no setter#
Gets an instance of the Indexed DB factory to being using Indexed DB.
Use dart:indexed_db.IdbFactory.supported to check if Indexed DB is supported on the current platform.
Implementation
@SupportedBrowser(SupportedBrowser.CHROME, '23.0')
@SupportedBrowser(SupportedBrowser.FIREFOX, '15.0')
@SupportedBrowser(SupportedBrowser.IE, '10.0')
IdbFactory? get indexedDB => JS(
'IdbFactory|Null', // If not supported, returns null.
'#.indexedDB || #.webkitIndexedDB || #.mozIndexedDB',
this,
this,
this,
);
innerHeight no setter#
The height of the viewport including scrollbars.
Other resources
- Window.innerHeight from MDN.
Implementation
int? get innerHeight native;
innerWidth no setter#
The width of the viewport including scrollbars.
Other resources
- Window.innerWidth from MDN.
Implementation
int? get innerWidth native;
isSecureContext no setter#
Implementation
bool? get isSecureContext native;
localStorage no setter#
Storage for this window that persists across sessions.
Other resources
- DOM storage guide from MDN.
- The past, present & future of local storage for web applications from Dive Into HTML5.
- Local storage specification from W3C.
Implementation
Storage get localStorage native;
location read / write override-getter#
getter:
The current location of this window.
Location currentLocation = window.location;
print(currentLocation.href); // 'http://www.example.com:80/'
setter:
Sets the window's location, which causes the browser to navigate to the new location.
Implementation
Location get location => _location;
set location(value) {
_location = value;
}
locationbar no setter#
This window's location bar, which displays the URL.
Other resources
- Browser interface elements from WHATWG.
Implementation
BarProp? get locationbar native;
menubar no setter#
This window's menu bar, which displays menu commands.
Other resources
- Browser interface elements from WHATWG.
Implementation
BarProp? get menubar native;
name read / write#
The name of this window.
Other resources
- Window.name from MDN.
Implementation
String? get name native;
set name(String? value) native;
navigator no setter#
The user agent accessing this window.
Other resources
- The navigator object from WHATWG.
Implementation
Navigator get navigator native;
offscreenBuffering no setter#
Whether objects are drawn offscreen before being displayed.
Other resources
- offscreenBuffering from WebPlatform.org.
Implementation
bool? get offscreenBuffering native;
on no setter inherited#
This is an ease-of-use accessor for event streams which should only be used when an explicit accessor is not available.
Inherited from EventTarget.
Implementation
Events get on => new Events(this);
onAbort no setter override#
Stream of abort events handled by this Window.
Implementation
Stream<Event> get onAbort => Element.abortEvent.forTarget(this);
onAnimationEnd no setter#
Stream of animationend events handled by this Window.
Implementation
Stream<AnimationEvent> get onAnimationEnd =>
animationEndEvent.forTarget(this);
onAnimationIteration no setter#
Stream of animationiteration events handled by this Window.
Implementation
Stream<AnimationEvent> get onAnimationIteration =>
animationIterationEvent.forTarget(this);
onAnimationStart no setter#
Stream of animationstart events handled by this Window.
Implementation
Stream<AnimationEvent> get onAnimationStart =>
animationStartEvent.forTarget(this);
onBeforeUnload no setter#
Stream of beforeunload events handled by this Window.
Implementation
Stream<Event> get onBeforeUnload => beforeUnloadEvent.forTarget(this);
onBlur no setter override#
Stream of blur events handled by this Window.
Implementation
Stream<Event> get onBlur => Element.blurEvent.forTarget(this);
onCanPlay no setter override#
Implementation
Stream<Event> get onCanPlay => Element.canPlayEvent.forTarget(this);
onCanPlayThrough no setter override#
Implementation
Stream<Event> get onCanPlayThrough =>
Element.canPlayThroughEvent.forTarget(this);
onChange no setter override#
Stream of change events handled by this Window.
Implementation
Stream<Event> get onChange => Element.changeEvent.forTarget(this);
onClick no setter override#
Stream of click events handled by this Window.
Implementation
Stream<MouseEvent> get onClick => Element.clickEvent.forTarget(this);
onContentLoaded no setter#
Stream of contentloaded events handled by this Window.
Implementation
Stream<Event> get onContentLoaded => contentLoadedEvent.forTarget(this);
onContextMenu no setter override#
Stream of contextmenu events handled by this Window.
Implementation
Stream<MouseEvent> get onContextMenu =>
Element.contextMenuEvent.forTarget(this);
onDeviceMotion no setter#
Stream of devicemotion events handled by this Window.
Implementation
Stream<DeviceMotionEvent> get onDeviceMotion =>
deviceMotionEvent.forTarget(this);
onDeviceOrientation no setter#
Stream of deviceorientation events handled by this Window.
Implementation
Stream<DeviceOrientationEvent> get onDeviceOrientation =>
deviceOrientationEvent.forTarget(this);
onDoubleClick no setter override#
Stream of doubleclick events handled by this Window.
Implementation
@DomName('Window.ondblclick')
Stream<Event> get onDoubleClick => Element.doubleClickEvent.forTarget(this);
onDrag no setter override#
Stream of drag events handled by this Window.
Implementation
Stream<MouseEvent> get onDrag => Element.dragEvent.forTarget(this);
onDragEnd no setter override#
Stream of dragend events handled by this Window.
Implementation
Stream<MouseEvent> get onDragEnd => Element.dragEndEvent.forTarget(this);
onDragEnter no setter override#
Stream of dragenter events handled by this Window.
Implementation
Stream<MouseEvent> get onDragEnter => Element.dragEnterEvent.forTarget(this);
onDragLeave no setter override#
Stream of dragleave events handled by this Window.
Implementation
Stream<MouseEvent> get onDragLeave => Element.dragLeaveEvent.forTarget(this);
onDragOver no setter override#
Stream of dragover events handled by this Window.
Implementation
Stream<MouseEvent> get onDragOver => Element.dragOverEvent.forTarget(this);
onDragStart no setter override#
Stream of dragstart events handled by this Window.
Implementation
Stream<MouseEvent> get onDragStart => Element.dragStartEvent.forTarget(this);
onDrop no setter override#
Stream of drop events handled by this Window.
Implementation
Stream<MouseEvent> get onDrop => Element.dropEvent.forTarget(this);
onDurationChange no setter override#
Implementation
Stream<Event> get onDurationChange =>
Element.durationChangeEvent.forTarget(this);
onEmptied no setter override#
Implementation
Stream<Event> get onEmptied => Element.emptiedEvent.forTarget(this);
onEnded no setter override#
Implementation
Stream<Event> get onEnded => Element.endedEvent.forTarget(this);
onError no setter override#
Stream of error events handled by this Window.
Implementation
Stream<Event> get onError => Element.errorEvent.forTarget(this);
onFocus no setter override#
Stream of focus events handled by this Window.
Implementation
Stream<Event> get onFocus => Element.focusEvent.forTarget(this);
onHashChange no setter override#
Stream of hashchange events handled by this Window.
Implementation
Stream<Event> get onHashChange => hashChangeEvent.forTarget(this);
onInput no setter override#
Stream of input events handled by this Window.
Implementation
Stream<Event> get onInput => Element.inputEvent.forTarget(this);
onInvalid no setter override#
Stream of invalid events handled by this Window.
Implementation
Stream<Event> get onInvalid => Element.invalidEvent.forTarget(this);
onKeyDown no setter override#
Stream of keydown events handled by this Window.
Implementation
Stream<KeyboardEvent> get onKeyDown => Element.keyDownEvent.forTarget(this);
onKeyPress no setter override#
Stream of keypress events handled by this Window.
Implementation
Stream<KeyboardEvent> get onKeyPress => Element.keyPressEvent.forTarget(this);
onKeyUp no setter override#
Stream of keyup events handled by this Window.
Implementation
Stream<KeyboardEvent> get onKeyUp => Element.keyUpEvent.forTarget(this);
onLoad no setter override#
Stream of load events handled by this Window.
Implementation
Stream<Event> get onLoad => Element.loadEvent.forTarget(this);
onLoadedData no setter override#
Implementation
Stream<Event> get onLoadedData => Element.loadedDataEvent.forTarget(this);
onLoadedMetadata no setter override#
Implementation
Stream<Event> get onLoadedMetadata =>
Element.loadedMetadataEvent.forTarget(this);
onLoadStart no setter#
Implementation
Stream<Event> get onLoadStart => loadStartEvent.forTarget(this);
onMessage no setter override#
Stream of message events handled by this Window.
Implementation
Stream<MessageEvent> get onMessage => messageEvent.forTarget(this);
onMouseDown no setter override#
Stream of mousedown events handled by this Window.
Implementation
Stream<MouseEvent> get onMouseDown => Element.mouseDownEvent.forTarget(this);
onMouseEnter no setter override#
Stream of mouseenter events handled by this Window.
Implementation
Stream<MouseEvent> get onMouseEnter =>
Element.mouseEnterEvent.forTarget(this);
onMouseLeave no setter override#
Stream of mouseleave events handled by this Window.
Implementation
Stream<MouseEvent> get onMouseLeave =>
Element.mouseLeaveEvent.forTarget(this);
onMouseMove no setter override#
Stream of mousemove events handled by this Window.
Implementation
Stream<MouseEvent> get onMouseMove => Element.mouseMoveEvent.forTarget(this);
onMouseOut no setter override#
Stream of mouseout events handled by this Window.
Implementation
Stream<MouseEvent> get onMouseOut => Element.mouseOutEvent.forTarget(this);
onMouseOver no setter override#
Stream of mouseover events handled by this Window.
Implementation
Stream<MouseEvent> get onMouseOver => Element.mouseOverEvent.forTarget(this);
onMouseUp no setter override#
Stream of mouseup events handled by this Window.
Implementation
Stream<MouseEvent> get onMouseUp => Element.mouseUpEvent.forTarget(this);
onMouseWheel no setter override#
Stream of mousewheel events handled by this Window.
Implementation
Stream<WheelEvent> get onMouseWheel =>
Element.mouseWheelEvent.forTarget(this);
onOffline no setter override#
Stream of offline events handled by this Window.
Implementation
Stream<Event> get onOffline => offlineEvent.forTarget(this);
onOnline no setter override#
Stream of online events handled by this Window.
Implementation
Stream<Event> get onOnline => onlineEvent.forTarget(this);
onPageHide no setter#
Stream of pagehide events handled by this Window.
Implementation
Stream<Event> get onPageHide => pageHideEvent.forTarget(this);
onPageShow no setter#
Stream of pageshow events handled by this Window.
Implementation
Stream<Event> get onPageShow => pageShowEvent.forTarget(this);
onPause no setter override#
Implementation
Stream<Event> get onPause => Element.pauseEvent.forTarget(this);
onPlay no setter override#
Implementation
Stream<Event> get onPlay => Element.playEvent.forTarget(this);
onPlaying no setter override#
Implementation
Stream<Event> get onPlaying => Element.playingEvent.forTarget(this);
onPopState no setter override#
Stream of popstate events handled by this Window.
Implementation
Stream<PopStateEvent> get onPopState => popStateEvent.forTarget(this);
onProgress no setter#
Implementation
Stream<Event> get onProgress => progressEvent.forTarget(this);
onRateChange no setter override#
Implementation
Stream<Event> get onRateChange => Element.rateChangeEvent.forTarget(this);
onReset no setter override#
Stream of reset events handled by this Window.
Implementation
Stream<Event> get onReset => Element.resetEvent.forTarget(this);
onResize no setter override#
Stream of resize events handled by this Window.
Implementation
Stream<Event> get onResize => Element.resizeEvent.forTarget(this);
onScroll no setter override#
Stream of scroll events handled by this Window.
Implementation
Stream<Event> get onScroll => Element.scrollEvent.forTarget(this);
onSearch no setter#
Stream of search events handled by this Window.
Implementation
Stream<Event> get onSearch => Element.searchEvent.forTarget(this);
onSeeked no setter override#
Implementation
Stream<Event> get onSeeked => Element.seekedEvent.forTarget(this);
onSeeking no setter override#
Implementation
Stream<Event> get onSeeking => Element.seekingEvent.forTarget(this);
onSelect no setter override#
Stream of select events handled by this Window.
Implementation
Stream<Event> get onSelect => Element.selectEvent.forTarget(this);
onStalled no setter override#
Implementation
Stream<Event> get onStalled => Element.stalledEvent.forTarget(this);
onStorage no setter override#
Stream of storage events handled by this Window.
Implementation
Stream<StorageEvent> get onStorage => storageEvent.forTarget(this);
onSubmit no setter override#
Stream of submit events handled by this Window.
Implementation
Stream<Event> get onSubmit => Element.submitEvent.forTarget(this);
onSuspend no setter override#
Implementation
Stream<Event> get onSuspend => Element.suspendEvent.forTarget(this);
onTimeUpdate no setter override#
Implementation
Stream<Event> get onTimeUpdate => Element.timeUpdateEvent.forTarget(this);
onTouchCancel no setter override#
Stream of touchcancel events handled by this Window.
Implementation
Stream<TouchEvent> get onTouchCancel =>
Element.touchCancelEvent.forTarget(this);
onTouchEnd no setter override#
Stream of touchend events handled by this Window.
Implementation
Stream<TouchEvent> get onTouchEnd => Element.touchEndEvent.forTarget(this);
onTouchMove no setter override#
Stream of touchmove events handled by this Window.
Implementation
Stream<TouchEvent> get onTouchMove => Element.touchMoveEvent.forTarget(this);
onTouchStart no setter override#
Stream of touchstart events handled by this Window.
Implementation
Stream<TouchEvent> get onTouchStart =>
Element.touchStartEvent.forTarget(this);
onTransitionEnd no setter#
Stream of transitionend events handled by this Window.
Implementation
Stream<TransitionEvent> get onTransitionEnd =>
Element.transitionEndEvent.forTarget(this);
onUnload no setter override#
Stream of unload events handled by this Window.
Implementation
Stream<Event> get onUnload => unloadEvent.forTarget(this);
onVolumeChange no setter override#
Implementation
Stream<Event> get onVolumeChange => Element.volumeChangeEvent.forTarget(this);
onWaiting no setter override#
Implementation
Stream<Event> get onWaiting => Element.waitingEvent.forTarget(this);
onWheel no setter override#
Stream of wheel events handled by this Window.
Implementation
Stream<WheelEvent> get onWheel => Element.wheelEvent.forTarget(this);
opener read / write override-getter#
A reference to the window that opened this one.
Window thisWindow = window;
WindowBase otherWindow = thisWindow.open('http://www.example.com/', 'foo');
print(otherWindow.opener == thisWindow); // 'true'
Implementation
WindowBase? get opener => _convertNativeToDart_Window(this._get_opener);
set opener(WindowBase? value) native;
orientation no setter#
Implementation
int? get orientation native;
origin no setter#
Implementation
String? get origin native;
outerHeight no setter#
The height of this window including all user interface elements.
Other resources
- Window.outerHeight from MDN.
Implementation
int get outerHeight native;
outerWidth no setter#
The width of the window including all user interface elements.
Other resources
- Window.outerWidth from MDN.
Implementation
int get outerWidth native;
pageXOffset no setter#
Implementation
int get pageXOffset => JS<num>('num', '#.pageXOffset', this).round();
pageYOffset no setter#
Implementation
int get pageYOffset => JS<num>('num', '#.pageYOffset', this).round();
parent no setter override#
A reference to the parent of this window.
If this WindowBase has no parent, parent will return a reference to the WindowBase itself.
IFrameElement myIFrame = new IFrameElement();
window.document.body.elements.add(myIFrame);
print(myIframe.contentWindow.parent == window) // 'true'
print(window.parent == window) // 'true'
Implementation
WindowBase? get parent => _convertNativeToDart_Window(this._get_parent);
performance no setter#
Timing and navigation data for this window.
Other resources
- Measuring page load speed with navigation timing from HTML5Rocks.
- Navigation timing specification from W3C.
Implementation
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.FIREFOX)
@SupportedBrowser(SupportedBrowser.IE)
Performance get performance native;
runtimeType no setter inherited#
Inherited from Interceptor.
Implementation
Type get runtimeType =>
getRuntimeTypeOfInterceptorNotArray(getInterceptor(this), this);
screen no setter#
Information about the screen displaying this window.
Other resources
- The Screen interface specification from W3C.
Implementation
Screen? get screen native;
screenLeft no setter#
The distance from the left side of the screen to the left side of this window.
Other resources
- The Screen interface specification from W3C.
Implementation
int? get screenLeft native;
screenTop no setter#
The distance from the top of the screen to the top of this window.
Other resources
- The Screen interface specification from W3C.
Implementation
int? get screenTop native;
screenX no setter#
The distance from the left side of the screen to the mouse pointer.
Other resources
- The Screen interface specification from W3C.
Implementation
int? get screenX native;
screenY no setter#
The distance from the top of the screen to the mouse pointer.
Other resources
- The Screen interface specification from W3C.
Implementation
int? get screenY native;
scrollbars no setter#
This window's scroll bars.
Other resources
- Browser interface elements from WHATWG.
Implementation
BarProp? get scrollbars native;
scrollX no setter#
The distance this window has been scrolled horizontally.
Other resources
- The Screen interface specification from W3C.
- scrollX from MDN.
Implementation
int get scrollX => JS<bool>('bool', '("scrollX" in #)', this)
? JS<num>('num', '#.scrollX', this).round()
: document.documentElement!.scrollLeft;
scrollY no setter#
The distance this window has been scrolled vertically.
Other resources
- The Screen interface specification from W3C.
- scrollY from MDN.
Implementation
int get scrollY => JS<bool>('bool', '("scrollY" in #)', this)
? JS<num>('num', '#.scrollY', this).round()
: document.documentElement!.scrollTop;
self no setter#
The current window.
Other resources
- Window.self from MDN.
Implementation
WindowBase? get self => _convertNativeToDart_Window(this._get_self);
sessionStorage no setter#
Storage for this window that is cleared when this session ends.
Other resources
- DOM storage guide from MDN.
- The past, present & future of local storage for web applications from Dive Into HTML5.
- Local storage specification from W3C.
Implementation
Storage get sessionStorage native;
speechSynthesis no setter#
Access to speech synthesis in the browser.
Other resources
- Web speech specification from W3C.
Implementation
SpeechSynthesis? get speechSynthesis native;
status read / write#
Deprecated.
Implementation
String? get status native;
set status(String? value) native;
statusbar no setter#
This window's status bar.
Other resources
- Browser interface elements from WHATWG.
Implementation
BarProp? get statusbar native;
styleMedia no setter#
Access to CSS media queries.
Other resources
- StyleMedia class reference from Safari Developer Library.
Implementation
StyleMedia? get styleMedia native;
toolbar no setter#
This window's tool bar.
Other resources
- Browser interface elements from WHATWG.
Implementation
BarProp? get toolbar native;
top no setter override#
A reference to the topmost window in the window hierarchy.
If this WindowBase is the topmost WindowBase, top will return a reference to the WindowBase itself.
// Add an IFrame to the current window.
IFrameElement myIFrame = new IFrameElement();
window.document.body.elements.add(myIFrame);
// Add an IFrame inside of the other IFrame.
IFrameElement innerIFrame = new IFrameElement();
myIFrame.elements.add(innerIFrame);
print(myIframe.contentWindow.top == window) // 'true'
print(innerIFrame.contentWindow.top == window) // 'true'
print(window.top == window) // 'true'
Implementation
WindowBase? get top => _convertNativeToDart_Window(this._get_top);
visualViewport no setter#
Implementation
VisualViewport? get visualViewport native;
window no setter#
The current window.
Other resources
- Window.window from MDN.
Implementation
WindowBase? get window => _convertNativeToDart_Window(this._get_window);
Methods#
addEventListener() inherited#
Inherited from EventTarget.
Implementation
void addEventListener(
String type,
EventListener? listener, [
bool? useCapture,
]) {
// TODO(leafp): This check is avoid a bug in our dispatch code when
// listener is null. The browser treats this call as a no-op in this
// case, so it's fine to short-circuit it, but we should not have to.
if (listener != null) {
_addEventListener(type, listener, useCapture);
}
}
alert()#
Displays a modal alert to the user.
Other resources
- User prompts from WHATWG.
Implementation
void alert([String? message]) native;
atob() override#
Implementation
String atob(String atob) native;
btoa() override#
Implementation
String btoa(String btoa) native;
cancelAnimationFrame()#
Cancels an animation frame request.
Other resources
- Window.cancelAnimationFrame from MDN.
Implementation
void cancelAnimationFrame(int id) {
_ensureRequestAnimationFrame();
_cancelAnimationFrame(id);
}
cancelIdleCallback()#
Implementation
void cancelIdleCallback(int handle) native;
close() override#
Closes the window.
This method should only succeed if the WindowBase object is script-closeable and the window calling close is allowed to navigate the window.
A window is script-closeable if it is either a window that was opened by another window, or if it is a window with only one document in its history.
A window might not be allowed to navigate, and therefore close, another window due to browser security features.
var other = window.open('http://www.example.com', 'foo');
// Closes other window, as it is script-closeable.
other.close();
print(other.closed); // 'true'
var newLocation = window.location
..href = 'http://www.mysite.com';
window.location = newLocation;
// Does not close this window, as the history has changed.
window.close();
print(window.closed); // 'false'
See also:
- Window close discussion from the W3C
Implementation
void close() native;
confirm()#
Displays a modal OK/Cancel prompt to the user.
Other resources
- User prompts from WHATWG.
Implementation
bool confirm([String? message]) native;
dispatchEvent() inherited#
Inherited from EventTarget.
Implementation
bool dispatchEvent(Event event) native;
fetch()#
Implementation
Future fetch(/*RequestInfo*/ input, [Map? init]) {
var init_dict = null;
if (init != null) {
init_dict = convertDartToNative_Dictionary(init);
}
return promiseToFuture(
JS("creates:_Response;", "#.fetch(#, #)", this, input, init_dict),
);
}
find()#
Finds text in this window.
Other resources
- Window.find from MDN.
Implementation
bool find(
String? string,
bool? caseSensitive,
bool? backwards,
bool? wrap,
bool? wholeWord,
bool? searchInFrames,
bool? showDialog,
) native;
getComputedStyleMap()#
Implementation
StylePropertyMapReadonly getComputedStyleMap(
Element element,
String? pseudoElement,
) native;
getMatchedCssRules()#
Returns all CSS rules that apply to the element's pseudo-element.
Implementation
@JSName('getMatchedCSSRules')
/**
* Returns all CSS rules that apply to the element's pseudo-element.
*/
@Returns('_CssRuleList')
@Creates('_CssRuleList')
List<CssRule> getMatchedCssRules(
Element? element,
String? pseudoElement,
) native;
getSelection()#
Returns the currently selected text.
Other resources
- Window.getSelection from MDN.
Implementation
Selection? getSelection() native;
matchMedia()#
Returns a list of media queries for the given query string.
Other resources
- Testing media queries from MDN.
- The MediaQueryList specification from W3C.
Implementation
MediaQueryList matchMedia(String query) native;
moveBy()#
Moves this window.
x and y can be negative.
Other resources
- Window.moveBy from MDN.
- Window.moveBy from W3C.
Implementation
void moveBy(int x, int y) native;
moveTo()#
Moves this window to a specific position.
x and y can be negative.
Other resources
- Window.moveTo from MDN.
- Window.moveTo from W3C.
Implementation
void moveTo(Point p) {
_moveTo(p.x.toInt(), p.y.toInt());
}
noSuchMethod() inherited#
Invoked when a nonexistent method or property is accessed.
A dynamic member invocation can attempt to call a member which doesn't exist on the receiving object. Example:
dynamic object = 1;
object.add(42); // Statically allowed, run-time error
This invalid code will invoke the noSuchMethod method
of the integer 1 with an Invocation
representing the
.add(42) call and arguments (which then throws).
Classes can override noSuchMethod to provide custom behavior for such invalid dynamic invocations.
A class with a non-default noSuchMethod invocation can also omit implementations for members of its interface. Example:
class MockList<T> implements List<T> {
noSuchMethod(Invocation invocation) {
log(invocation);
super.noSuchMethod(invocation); // Will throw.
}
}
void main() {
MockList().add(42);
}
This code has no compile-time warnings or errors even though
the MockList class has no concrete implementation of
any of the List interface methods.
Calls to List methods are forwarded to noSuchMethod,
so this code will log an invocation similar to
Invocation.method(#add, [42])
and then throw.
If a value is returned from noSuchMethod,
it becomes the result of the original invocation.
If the value is not of a type that can be returned by the original
invocation, a type error occurs at the invocation.
The default behavior is to throw a NoSuchMethodError.
Inherited from Interceptor.
Implementation
dynamic noSuchMethod(Invocation invocation) {
throw NoSuchMethodError.withInvocation(this, invocation);
}
open()#
Opens a new window.
Other resources
- Window.open from MDN.
Implementation
WindowBase open(String url, String name, [String? options]) {
final win = options == null
? _open2(url, name)
: _open3(url, name, options);
return _DOMWindowCrossFrame._createSafe(win);
}
postMessage() override#
Sends a cross-origin message.
Other resources
- window.postMessage from MDN.
- Cross-document messaging from WHATWG.
Implementation
void postMessage(
/*any*/ message,
String targetOrigin, [
List<Object>? transfer,
]) {
if (transfer != null) {
var message_1 = convertDartToNative_SerializedScriptValue(message);
_postMessage_1(message_1, targetOrigin, transfer);
return;
}
var message_1 = convertDartToNative_SerializedScriptValue(message);
_postMessage_2(message_1, targetOrigin);
return;
}
print()#
Opens the print dialog for this window.
Other resources
- Window.print from MDN.
Implementation
void print() native;
removeEventListener() inherited#
Inherited from EventTarget.
Implementation
void removeEventListener(
String type,
EventListener? listener, [
bool? useCapture,
]) {
// TODO(leafp): This check is avoid a bug in our dispatch code when
// listener is null. The browser treats this call as a no-op in this
// case, so it's fine to short-circuit it, but we should not have to.
if (listener != null) {
_removeEventListener(type, listener, useCapture);
}
}
requestAnimationFrame()#
Called to draw an animation frame and then request the window to repaint
after callback has finished (creating the animation).
Use this method only if you need to later call cancelAnimationFrame. If not, the preferred Dart idiom is to set animation frames by calling animationFrame, which returns a Future.
Returns a non-zero valued integer to represent the request id for this request. This value only needs to be saved if you intend to call cancelAnimationFrame so you can specify the particular animation to cancel.
Note: The supplied callback needs to call requestAnimationFrame
again
for the animation to continue.
Implementation
int requestAnimationFrame(FrameRequestCallback callback) {
_ensureRequestAnimationFrame();
return _requestAnimationFrame(_wrapZone(callback)!);
}
requestFileSystem()#
Access a sandboxed file system of size bytes.
If persistent is true, the application will request permission from the
user to create lasting storage. This storage cannot be freed without the
user's permission. Returns a Future
whose value stores a reference to
the sandboxed file system for use. Because the file system is sandboxed,
applications cannot access file systems created in other web pages.
Implementation
Future<FileSystem> requestFileSystem(int size, {bool persistent = false}) {
return _requestFileSystem(persistent ? 1 : 0, size);
}
requestIdleCallback()#
Implementation
int requestIdleCallback(IdleRequestCallback callback, [Map? options]) {
if (options != null) {
var callback_1 = convertDartClosureToJS(callback, 1);
var options_2 = convertDartToNative_Dictionary(options);
return _requestIdleCallback_1(callback_1, options_2);
}
var callback_1 = convertDartClosureToJS(callback, 1);
return _requestIdleCallback_2(callback_1);
}
resizeBy()#
Resizes this window by an offset.
Other resources
- Window.resizeBy from MDN.
Implementation
void resizeBy(int x, int y) native;
resizeTo()#
Resizes this window to a specific width and height.
Other resources
- Window.resizeTo from MDN.
Implementation
void resizeTo(int x, int y) native;
resolveLocalFileSystemUrl()#
Asynchronously retrieves a local filesystem entry.
Other resources
Implementation
@JSName('webkitResolveLocalFileSystemURL')
/**
* Asynchronously retrieves a local filesystem entry.
*
* ## Other resources
*
* * [Obtaining access to file system entry
* points](http://www.w3.org/TR/file-system-api/#obtaining-access-to-file-system-entry-points)
* from W3C.
*/
@SupportedBrowser(SupportedBrowser.CHROME)
Future<Entry> resolveLocalFileSystemUrl(String url) {
var completer = new Completer<Entry>();
_resolveLocalFileSystemUrl(
url,
(value) {
completer.complete(value);
},
(error) {
completer.completeError(error);
},
);
return completer.future;
}
scroll()#
Scrolls the page horizontally and vertically to a specific point.
This method is identical to scrollTo.
Other resources
- Window.scroll from MDN.
Implementation
void scroll([options_OR_x, y, Map? scrollOptions]) {
if (options_OR_x == null && y == null && scrollOptions == null) {
_scroll_1();
return;
}
if ((options_OR_x is Map) && y == null && scrollOptions == null) {
var options_1 = convertDartToNative_Dictionary(options_OR_x);
_scroll_2(options_1);
return;
}
if ((y is num) && (options_OR_x is num) && scrollOptions == null) {
_scroll_3(options_OR_x, y);
return;
}
if ((y is int) && (options_OR_x is int) && scrollOptions == null) {
_scroll_4(options_OR_x, y);
return;
}
if (scrollOptions != null && (y is int) && (options_OR_x is int)) {
var scrollOptions_1 = convertDartToNative_Dictionary(scrollOptions);
_scroll_5(options_OR_x, y, scrollOptions_1);
return;
}
throw new ArgumentError("Incorrect number or type of arguments");
}
scrollBy()#
Scrolls the page horizontally and vertically by an offset.
Other resources
- Window.scrollBy from MDN.
Implementation
void scrollBy([options_OR_x, y, Map? scrollOptions]) {
if (options_OR_x == null && y == null && scrollOptions == null) {
_scrollBy_1();
return;
}
if ((options_OR_x is Map) && y == null && scrollOptions == null) {
var options_1 = convertDartToNative_Dictionary(options_OR_x);
_scrollBy_2(options_1);
return;
}
if ((y is num) && (options_OR_x is num) && scrollOptions == null) {
_scrollBy_3(options_OR_x, y);
return;
}
if ((y is int) && (options_OR_x is int) && scrollOptions == null) {
_scrollBy_4(options_OR_x, y);
return;
}
if (scrollOptions != null && (y is int) && (options_OR_x is int)) {
var scrollOptions_1 = convertDartToNative_Dictionary(scrollOptions);
_scrollBy_5(options_OR_x, y, scrollOptions_1);
return;
}
throw new ArgumentError("Incorrect number or type of arguments");
}
scrollTo()#
Scrolls the page horizontally and vertically to a specific point.
This method is identical to scroll.
Other resources
- Window.scrollTo from MDN.
Implementation
void scrollTo([options_OR_x, y, Map? scrollOptions]) {
if (options_OR_x == null && y == null && scrollOptions == null) {
_scrollTo_1();
return;
}
if ((options_OR_x is Map) && y == null && scrollOptions == null) {
var options_1 = convertDartToNative_Dictionary(options_OR_x);
_scrollTo_2(options_1);
return;
}
if ((y is num) && (options_OR_x is num) && scrollOptions == null) {
_scrollTo_3(options_OR_x, y);
return;
}
if ((y is int) && (options_OR_x is int) && scrollOptions == null) {
_scrollTo_4(options_OR_x, y);
return;
}
if (scrollOptions != null && (y is int) && (options_OR_x is int)) {
var scrollOptions_1 = convertDartToNative_Dictionary(scrollOptions);
_scrollTo_5(options_OR_x, y, scrollOptions_1);
return;
}
throw new ArgumentError("Incorrect number or type of arguments");
}
stop()#
Stops the window from loading.
Other resources
- The Window object from W3C.
Implementation
void stop() native;
toString() inherited#
A string representation of this object.
Some classes have a default textual representation,
often paired with a static parse function (like int.parse).
These classes will provide the textual representation as
their string representation.
Other classes have no meaningful textual representation
that a program will care about.
Such classes will typically override toString to provide
useful information when inspecting the object,
mainly for debugging or logging.
Inherited from Interceptor.
Implementation
String toString() => Primitives.objectToHumanReadableString(this);
Operators#
operator ==() inherited#
The equality operator.
The default behavior for all Objects is to return true if and
only if this object and other are the same object.
Override this method to specify a different equality relation on a class. The overriding method must still be an equivalence relation. That is, it must be:
Total: It must return a boolean for all arguments. It should never throw.
Reflexive: For all objects
o,o == omust be true.-
Symmetric: For all objects
o1ando2,o1 == o2ando2 == o1must either both be true, or both be false. -
Transitive: For all objects
o1,o2, ando3, ifo1 == o2ando2 == o3are true, theno1 == o3must be true.
The method should also be consistent over time, so whether two objects are equal should only change if at least one of the objects was modified.
If a subclass overrides the equality operator, it should override the hashCode method as well to maintain consistency.
Inherited from Interceptor.
Implementation
bool operator ==(Object other) => identical(this, other);
Static Properties#
supportsPointConversions no setter#
convertPointFromNodeToPage and convertPointFromPageToNode are removed. see http://dev.w3.org/csswg/cssom-view/#geometry
Implementation
static bool get supportsPointConversions => DomPoint.supported;
Constants#
animationEndEvent#
Static factory designed to expose animationend events to event
handlers that are not necessarily instances of Window.
See EventStreamProvider for usage information.
Implementation
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
static const EventStreamProvider<AnimationEvent> animationEndEvent =
const EventStreamProvider<AnimationEvent>('webkitAnimationEnd');
animationIterationEvent#
Static factory designed to expose animationiteration events to event
handlers that are not necessarily instances of Window.
See EventStreamProvider for usage information.
Implementation
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
static const EventStreamProvider<AnimationEvent> animationIterationEvent =
const EventStreamProvider<AnimationEvent>('webkitAnimationIteration');
animationStartEvent#
Static factory designed to expose animationstart events to event
handlers that are not necessarily instances of Window.
See EventStreamProvider for usage information.
Implementation
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
static const EventStreamProvider<AnimationEvent> animationStartEvent =
const EventStreamProvider<AnimationEvent>('webkitAnimationStart');
beforeUnloadEvent#
Static factory designed to expose beforeunload events to event
handlers that are not necessarily instances of Window.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<BeforeUnloadEvent> beforeUnloadEvent =
const EventStreamProvider('beforeunload');
contentLoadedEvent#
Static factory designed to expose contentloaded events to event
handlers that are not necessarily instances of Window.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<Event> contentLoadedEvent =
const EventStreamProvider<Event>('DOMContentLoaded');
deviceMotionEvent#
Static factory designed to expose devicemotion events to event
handlers that are not necessarily instances of Window.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<DeviceMotionEvent> deviceMotionEvent =
const EventStreamProvider<DeviceMotionEvent>('devicemotion');
deviceOrientationEvent#
Static factory designed to expose deviceorientation events to event
handlers that are not necessarily instances of Window.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<DeviceOrientationEvent>
deviceOrientationEvent = const EventStreamProvider<DeviceOrientationEvent>(
'deviceorientation',
);
hashChangeEvent#
Static factory designed to expose hashchange events to event
handlers that are not necessarily instances of Window.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<Event> hashChangeEvent =
const EventStreamProvider<Event>('hashchange');
loadStartEvent#
Implementation
static const EventStreamProvider<Event> loadStartEvent =
const EventStreamProvider<Event>('loadstart');
messageEvent#
Static factory designed to expose message events to event
handlers that are not necessarily instances of Window.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<MessageEvent> messageEvent =
const EventStreamProvider<MessageEvent>('message');
offlineEvent#
Static factory designed to expose offline events to event
handlers that are not necessarily instances of Window.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<Event> offlineEvent =
const EventStreamProvider<Event>('offline');
onlineEvent#
Static factory designed to expose online events to event
handlers that are not necessarily instances of Window.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<Event> onlineEvent =
const EventStreamProvider<Event>('online');
pageHideEvent#
Static factory designed to expose pagehide events to event
handlers that are not necessarily instances of Window.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<Event> pageHideEvent =
const EventStreamProvider<Event>('pagehide');
pageShowEvent#
Static factory designed to expose pageshow events to event
handlers that are not necessarily instances of Window.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<Event> pageShowEvent =
const EventStreamProvider<Event>('pageshow');
PERSISTENT#
Indicates that file system data cannot be cleared unless given user permission.
Other resources
- Exploring the FileSystem APIs from HTML5Rocks.
- File API from W3C.
Implementation
static const int PERSISTENT = 1;
popStateEvent#
Static factory designed to expose popstate events to event
handlers that are not necessarily instances of Window.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<PopStateEvent> popStateEvent =
const EventStreamProvider<PopStateEvent>('popstate');
progressEvent#
Implementation
static const EventStreamProvider<Event> progressEvent =
const EventStreamProvider<Event>('progress');
storageEvent#
Static factory designed to expose storage events to event
handlers that are not necessarily instances of Window.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<StorageEvent> storageEvent =
const EventStreamProvider<StorageEvent>('storage');
TEMPORARY#
Indicates that file system data can be cleared at any time.
Other resources
- Exploring the FileSystem APIs from HTML5Rocks.
- File API from W3C.
Implementation
static const int TEMPORARY = 0;
unloadEvent#
Static factory designed to expose unload events to event
handlers that are not necessarily instances of Window.
See EventStreamProvider for usage information.
Implementation
static const EventStreamProvider<Event> unloadEvent =
const EventStreamProvider<Event>('unload');