Window class
@DomName('Window')
class Window extends EventTarget implements WindowBase native "Window,DOMWindow" {
/**
* Executes a [callback] after the immediate execution stack has completed.
*
* This differs from using Timer.run(callback)
* because Timer will run in about 4-15 milliseconds, depending on browser,
* depending on load. [setImmediate], in contrast, makes browser-specific
* changes in behavior to attempt to run immediately after the current
* frame unwinds, causing the future to complete after all processing has
* completed for the current event, but before any subsequent events.
*/
void setImmediate(TimeoutHandler callback) {
_addMicrotaskCallback(callback);
}
/**
* Lookup a port by its [name]. Return null if no port is
* registered under [name].
*/
SendPortSync lookupPort(String name) {
var portStr = document.documentElement.attributes['dart-port:$name'];
if (portStr == null) {
return null;
}
var port = json.parse(portStr);
return _deserialize(port);
}
/**
* Register a [port] on this window under the given [name]. This
* port may be retrieved by any isolate (or JavaScript script)
* running in this window.
*/
void registerPort(String name, var port) {
var serialized = _serialize(port);
document.documentElement.attributes['dart-port:$name'] =
json.stringify(serialized);
}
/**
* 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.
*/
Future<num> get animationFrame {
var completer = new Completer<num>();
requestAnimationFrame((time) {
completer.complete(time);
});
return completer.future;
}
Document get document => JS('Document', '#.document', this);
WindowBase _open2(url, name) => JS('Window', '#.open(#,#)', this, url, name);
WindowBase _open3(url, name, options) =>
JS('Window', '#.open(#,#,#)', this, url, name, options);
WindowBase open(String url, String name, [String options]) {
if (options == null) {
return _DOMWindowCrossFrame._createSafe(_open2(url, name));
} else {
return _DOMWindowCrossFrame._createSafe(_open3(url, name, options));
}
}
// API level getter and setter for Location.
// TODO: The cross domain safe wrapper can be inserted here or folded into
// _LocationWrapper.
Location get location {
// Firefox work-around for Location. The Firefox location object cannot be
// made to behave like a Dart object so must be wrapped.
var result = _location;
if (_isDartLocation(result)) return result; // e.g. on Chrome.
if (null == _location_wrapper) {
_location_wrapper = new _LocationWrapper(result);
}
return _location_wrapper;
}
// TODO: consider forcing users to do: window.location.assign('string').
/**
* Sets the window's location, which causes the browser to navigate to the new
* location. [value] may be a Location object or a string.
*/
void set location(value) {
if (value is _LocationWrapper) {
_location = value._ptr;
} else {
_location = value;
}
}
_LocationWrapper _location_wrapper; // Cached wrapped Location object.
// Native getter and setter to access raw Location object.
dynamic get _location => JS('Location|=Object', '#.location', this);
void set _location(value) {
JS('void', '#.location = #', this, value);
}
// Prevent compiled from thinking 'location' property is available for a Dart
// member.
@JSName('location')
_protect_location() native;
static _isDartLocation(thing) {
// On Firefox the code that implements 'is Location' fails to find the patch
// stub on Object.prototype and throws an exception.
try {
return thing is Location;
} catch (e) {
return false;
}
}
/**
* 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.
*/
@DomName('DOMWindow.requestAnimationFrame')
int requestAnimationFrame(RequestAnimationFrameCallback callback) {
_ensureRequestAnimationFrame();
return _requestAnimationFrame(callback);
}
void cancelAnimationFrame(int id) {
_ensureRequestAnimationFrame();
_cancelAnimationFrame(id);
}
@JSName('requestAnimationFrame')
int _requestAnimationFrame(RequestAnimationFrameCallback callback) native;
@JSName('cancelAnimationFrame')
void _cancelAnimationFrame(int id) native;
_ensureRequestAnimationFrame() {
if (JS('bool',
'!!(#.requestAnimationFrame && #.cancelAnimationFrame)', this, this))
return;
JS('void',
r"""
(function($this) {
var vendors = ['ms', 'moz', 'webkit', 'o'];
for (var i = 0; i < vendors.length && !$this.requestAnimationFrame; ++i) {
$this.requestAnimationFrame = $this[vendors[i] + 'RequestAnimationFrame'];
$this.cancelAnimationFrame =
$this[vendors[i]+'CancelAnimationFrame'] ||
$this[vendors[i]+'CancelRequestAnimationFrame'];
}
if ($this.requestAnimationFrame && $this.cancelAnimationFrame) return;
$this.requestAnimationFrame = function(callback) {
return window.setTimeout(function() {
callback(Date.now());
}, 16 /* 16ms ~= 60fps */);
};
$this.cancelAnimationFrame = function(id) { clearTimeout(id); }
})(#)""",
this);
}
/**
* Gets an instance of the Indexed DB factory to being using Indexed DB.
*
* Use [IdbFactory.supported] to check if Indexed DB is supported on the
* current platform.
*/
@SupportedBrowser(SupportedBrowser.CHROME, '23.0')
@SupportedBrowser(SupportedBrowser.FIREFOX, '15.0')
@SupportedBrowser(SupportedBrowser.IE, '10.0')
@Experimental
IdbFactory get indexedDB =>
JS('IdbFactory|Null', // If not supported, returns `null`.
'#.indexedDB || #.webkitIndexedDB || #.mozIndexedDB',
this, this, this);
@DomName('Window.console')
Console get console => Console._safeConsole;
/// Checks if _setImmediate is supported.
static bool get _supportsSetImmediate =>
JS('bool', '!!(window.setImmediate)');
// Set immediate implementation for IE
void _setImmediate(void callback()) {
JS('void', '#.setImmediate(#)', this, convertDartClosureToJS(callback, 0));
}
/**
* Access a sandboxed file system of the specified `size`. 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.
*/
Future<FileSystem> requestFileSystem(int size, {bool persistent: false}) {
return _requestFileSystem(persistent? 1 : 0, size);
}
@DomName('DOMWindow.convertPointFromNodeToPage')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
Point convertPointFromNodeToPage(Node node, Point point) {
var result = _convertPointFromNodeToPage(node,
new _DomPoint(point.x, point.y));
return new Point(result.x, result.y);
}
@DomName('DOMWindow.convertPointFromPageToNode')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
Point convertPointFromPageToNode(Node node, Point point) {
var result = _convertPointFromPageToNode(node,
new _DomPoint(point.x, point.y));
return new Point(result.x, result.y);
}
/**
* Checks whether [convertPointFromNodeToPage] and
* [convertPointFromPageToNode] are supported on the current platform.
*/
static bool get supportsPointConversions => _DomPoint.supported;
@DomName('Window.DOMContentLoadedEvent')
@DocsEditable
static const EventStreamProvider<Event> contentLoadedEvent = const EventStreamProvider<Event>('DOMContentLoaded');
@DomName('Window.devicemotionEvent')
@DocsEditable
// http://dev.w3.org/geo/api/spec-source-orientation.html#devicemotion
@Experimental
static const EventStreamProvider<DeviceMotionEvent> deviceMotionEvent = const EventStreamProvider<DeviceMotionEvent>('devicemotion');
@DomName('Window.deviceorientationEvent')
@DocsEditable
// http://dev.w3.org/geo/api/spec-source-orientation.html#devicemotion
@Experimental
static const EventStreamProvider<DeviceOrientationEvent> deviceOrientationEvent = const EventStreamProvider<DeviceOrientationEvent>('deviceorientation');
@DomName('Window.hashchangeEvent')
@DocsEditable
static const EventStreamProvider<Event> hashChangeEvent = const EventStreamProvider<Event>('hashchange');
@DomName('Window.messageEvent')
@DocsEditable
static const EventStreamProvider<MessageEvent> messageEvent = const EventStreamProvider<MessageEvent>('message');
@DomName('Window.offlineEvent')
@DocsEditable
static const EventStreamProvider<Event> offlineEvent = const EventStreamProvider<Event>('offline');
@DomName('Window.onlineEvent')
@DocsEditable
static const EventStreamProvider<Event> onlineEvent = const EventStreamProvider<Event>('online');
@DomName('Window.pagehideEvent')
@DocsEditable
static const EventStreamProvider<Event> pageHideEvent = const EventStreamProvider<Event>('pagehide');
@DomName('Window.pageshowEvent')
@DocsEditable
static const EventStreamProvider<Event> pageShowEvent = const EventStreamProvider<Event>('pageshow');
@DomName('Window.popstateEvent')
@DocsEditable
static const EventStreamProvider<PopStateEvent> popStateEvent = const EventStreamProvider<PopStateEvent>('popstate');
@DomName('Window.resizeEvent')
@DocsEditable
static const EventStreamProvider<Event> resizeEvent = const EventStreamProvider<Event>('resize');
@DomName('Window.storageEvent')
@DocsEditable
static const EventStreamProvider<StorageEvent> storageEvent = const EventStreamProvider<StorageEvent>('storage');
@DomName('Window.unloadEvent')
@DocsEditable
static const EventStreamProvider<Event> unloadEvent = const EventStreamProvider<Event>('unload');
@DomName('Window.webkitAnimationEndEvent')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
static const EventStreamProvider<AnimationEvent> animationEndEvent = const EventStreamProvider<AnimationEvent>('webkitAnimationEnd');
@DomName('Window.webkitAnimationIterationEvent')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
static const EventStreamProvider<AnimationEvent> animationIterationEvent = const EventStreamProvider<AnimationEvent>('webkitAnimationIteration');
@DomName('Window.webkitAnimationStartEvent')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
static const EventStreamProvider<AnimationEvent> animationStartEvent = const EventStreamProvider<AnimationEvent>('webkitAnimationStart');
@DomName('Window.PERSISTENT')
@DocsEditable
// http://www.w3.org/TR/file-system-api/#idl-def-LocalFileSystem
@Experimental
static const int PERSISTENT = 1;
@DomName('Window.TEMPORARY')
@DocsEditable
// http://www.w3.org/TR/file-system-api/#idl-def-LocalFileSystem
@Experimental
static const int TEMPORARY = 0;
@JSName('CSS')
@DomName('Window.CSS')
@DocsEditable
final Css css;
@DomName('Window.applicationCache')
@DocsEditable
final ApplicationCache applicationCache;
@DomName('Window.closed')
@DocsEditable
final bool closed;
@DomName('Window.crypto')
@DocsEditable
// http://www.w3.org/TR/WebCryptoAPI/
@Experimental
final Crypto crypto;
@DomName('Window.defaultStatus')
@DocsEditable
String defaultStatus;
@DomName('Window.defaultstatus')
@DocsEditable
@Experimental // non-standard
String defaultstatus;
@DomName('Window.devicePixelRatio')
@DocsEditable
// http://www.quirksmode.org/blog/archives/2012/06/devicepixelrati.html
@Experimental // non-standard
final num devicePixelRatio;
@DomName('Window.event')
@DocsEditable
@deprecated // deprecated
final Event event;
@DomName('Window.history')
@DocsEditable
final History history;
@DomName('Window.innerHeight')
@DocsEditable
final int innerHeight;
@DomName('Window.innerWidth')
@DocsEditable
final int innerWidth;
@DomName('Window.localStorage')
@DocsEditable
final Storage localStorage;
@DomName('Window.locationbar')
@DocsEditable
final BarProp locationbar;
@DomName('Window.menubar')
@DocsEditable
final BarProp menubar;
@DomName('Window.name')
@DocsEditable
String name;
@DomName('Window.navigator')
@DocsEditable
final Navigator navigator;
@DomName('Window.offscreenBuffering')
@DocsEditable
@Experimental // non-standard
final bool offscreenBuffering;
WindowBase get opener => _convertNativeToDart_Window(this._get_opener);
@JSName('opener')
@DomName('Window.opener')
@DocsEditable
@Creates('Window|=Object')
@Returns('Window|=Object')
final dynamic _get_opener;
@DomName('Window.outerHeight')
@DocsEditable
final int outerHeight;
@DomName('Window.outerWidth')
@DocsEditable
final int outerWidth;
@DomName('Window.pageXOffset')
@DocsEditable
final int pageXOffset;
@DomName('Window.pageYOffset')
@DocsEditable
final int pageYOffset;
WindowBase get parent => _convertNativeToDart_Window(this._get_parent);
@JSName('parent')
@DomName('Window.parent')
@DocsEditable
@Creates('Window|=Object')
@Returns('Window|=Object')
final dynamic _get_parent;
@DomName('Window.performance')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.FIREFOX)
@SupportedBrowser(SupportedBrowser.IE)
final Performance performance;
@DomName('Window.personalbar')
@DocsEditable
// https://developer.mozilla.org/en-US/docs/DOM/window.personalbar
@deprecated // deprecated
final BarProp personalbar;
@DomName('Window.screen')
@DocsEditable
final Screen screen;
@DomName('Window.screenLeft')
@DocsEditable
final int screenLeft;
@DomName('Window.screenTop')
@DocsEditable
final int screenTop;
@DomName('Window.screenX')
@DocsEditable
final int screenX;
@DomName('Window.screenY')
@DocsEditable
final int screenY;
@DomName('Window.scrollX')
@DocsEditable
final int scrollX;
@DomName('Window.scrollY')
@DocsEditable
final int scrollY;
@DomName('Window.scrollbars')
@DocsEditable
final BarProp scrollbars;
WindowBase get self => _convertNativeToDart_Window(this._get_self);
@JSName('self')
@DomName('Window.self')
@DocsEditable
@Creates('Window|=Object')
@Returns('Window|=Object')
final dynamic _get_self;
@DomName('Window.sessionStorage')
@DocsEditable
final Storage sessionStorage;
@DomName('Window.speechSynthesis')
@DocsEditable
// https://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html#tts-section
@Experimental
final SpeechSynthesis speechSynthesis;
@DomName('Window.status')
@DocsEditable
String status;
@DomName('Window.statusbar')
@DocsEditable
final BarProp statusbar;
@DomName('Window.styleMedia')
@DocsEditable
// http://developer.apple.com/library/safari/#documentation/SafariDOMAdditions/Reference/StyleMedia/StyleMedia/StyleMedia.html
@Experimental // nonstandard
final StyleMedia styleMedia;
@DomName('Window.toolbar')
@DocsEditable
final BarProp toolbar;
WindowBase get top => _convertNativeToDart_Window(this._get_top);
@JSName('top')
@DomName('Window.top')
@DocsEditable
@Creates('Window|=Object')
@Returns('Window|=Object')
final dynamic _get_top;
@JSName('webkitNotifications')
@DomName('Window.webkitNotifications')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
// https://plus.sandbox.google.com/u/0/+GoogleChromeDevelopers/posts/8vWo8hq4pDm?e=Showroom
@deprecated // deprecated
final NotificationCenter notifications;
@JSName('webkitStorageInfo')
@DomName('Window.webkitStorageInfo')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
// http://www.w3.org/TR/file-system-api/
@deprecated // deprecated
final StorageInfo storageInfo;
WindowBase get window => _convertNativeToDart_Window(this._get_window);
@JSName('window')
@DomName('Window.window')
@DocsEditable
@Creates('Window|=Object')
@Returns('Window|=Object')
final dynamic _get_window;
@DomName('Window.__getter__')
@DocsEditable
@Creates('Window|=Object')
@Returns('Window|=Object')
WindowBase __getter__(index_OR_name) {
if ((index_OR_name is int || index_OR_name == null)) {
return _convertNativeToDart_Window(___getter___1(index_OR_name));
}
if ((index_OR_name is String || index_OR_name == null)) {
return _convertNativeToDart_Window(___getter___2(index_OR_name));
}
throw new ArgumentError("Incorrect number or type of arguments");
}
@JSName('__getter__')
@DomName('Window.__getter__')
@DocsEditable
@Creates('Window|=Object')
@Returns('Window|=Object')
___getter___1(int index) native;
@JSName('__getter__')
@DomName('Window.__getter__')
@DocsEditable
@Creates('Window|=Object')
@Returns('Window|=Object')
___getter___2(String name) native;
@JSName('addEventListener')
@DomName('Window.addEventListener')
@DocsEditable
void $dom_addEventListener(String type, EventListener listener, [bool useCapture]) native;
@DomName('Window.alert')
@DocsEditable
void alert(String message) native;
@DomName('Window.atob')
@DocsEditable
String atob(String string) native;
@DomName('Window.btoa')
@DocsEditable
String btoa(String string) native;
@JSName('clearInterval')
@DomName('Window.clearInterval')
@DocsEditable
void _clearInterval(int handle) native;
@JSName('clearTimeout')
@DomName('Window.clearTimeout')
@DocsEditable
void _clearTimeout(int handle) native;
@DomName('Window.close')
@DocsEditable
void close() native;
@DomName('Window.confirm')
@DocsEditable
bool confirm(String message) native;
@DomName('Window.dispatchEvent')
@DocsEditable
bool dispatchEvent(Event evt) native;
@DomName('Window.find')
@DocsEditable
@Experimental // non-standard
bool find(String string, bool caseSensitive, bool backwards, bool wrap, bool wholeWord, bool searchInFrames, bool showDialog) native;
@JSName('getComputedStyle')
@DomName('Window.getComputedStyle')
@DocsEditable
CssStyleDeclaration $dom_getComputedStyle(Element element, String pseudoElement) native;
@JSName('getMatchedCSSRules')
@DomName('Window.getMatchedCSSRules')
@DocsEditable
@Experimental // non-standard
@Returns('_CssRuleList')
@Creates('_CssRuleList')
List<CssRule> getMatchedCssRules(Element element, String pseudoElement) native;
@DomName('Window.getSelection')
@DocsEditable
Selection getSelection() native;
@DomName('Window.matchMedia')
@DocsEditable
MediaQueryList matchMedia(String query) native;
@DomName('Window.moveBy')
@DocsEditable
void moveBy(num x, num y) native;
@DomName('Window.moveTo')
@DocsEditable
void moveTo(num x, num y) native;
@DomName('Window.openDatabase')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
// http://www.w3.org/TR/webdatabase/
@Experimental // deprecated
@Creates('SqlDatabase')
SqlDatabase openDatabase(String name, String version, String displayName, int estimatedSize, [DatabaseCallback creationCallback]) native;
@DomName('Window.postMessage')
@DocsEditable
void postMessage(/*SerializedScriptValue*/ message, String targetOrigin, [List messagePorts]) {
if (messagePorts != null) {
var message_1 = convertDartToNative_SerializedScriptValue(message);
_postMessage_1(message_1, targetOrigin, messagePorts);
return;
}
var message_2 = convertDartToNative_SerializedScriptValue(message);
_postMessage_2(message_2, targetOrigin);
return;
}
@JSName('postMessage')
@DomName('Window.postMessage')
@DocsEditable
void _postMessage_1(message, targetOrigin, List messagePorts) native;
@JSName('postMessage')
@DomName('Window.postMessage')
@DocsEditable
void _postMessage_2(message, targetOrigin) native;
@DomName('Window.print')
@DocsEditable
void print() native;
@JSName('removeEventListener')
@DomName('Window.removeEventListener')
@DocsEditable
void $dom_removeEventListener(String type, EventListener listener, [bool useCapture]) native;
@DomName('Window.resizeBy')
@DocsEditable
void resizeBy(num x, num y) native;
@DomName('Window.resizeTo')
@DocsEditable
void resizeTo(num width, num height) native;
@DomName('Window.scroll')
@DocsEditable
void scroll(int x, int y) native;
@DomName('Window.scrollBy')
@DocsEditable
void scrollBy(int x, int y) native;
@DomName('Window.scrollTo')
@DocsEditable
void scrollTo(int x, int y) native;
@JSName('setInterval')
@DomName('Window.setInterval')
@DocsEditable
int _setInterval(Object handler, int timeout) native;
@JSName('setTimeout')
@DomName('Window.setTimeout')
@DocsEditable
int _setTimeout(Object handler, int timeout) native;
@DomName('Window.showModalDialog')
@DocsEditable
@Creates('Null')
Object showModalDialog(String url, [Object dialogArgs, String featureArgs]) native;
@DomName('Window.stop')
@DocsEditable
void stop() native;
@DomName('Window.toString')
@DocsEditable
String toString() native;
@JSName('webkitConvertPointFromNodeToPage')
@DomName('Window.webkitConvertPointFromNodeToPage')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
// http://developer.apple.com/library/safari/#documentation/DataManagement/Reference/DOMWindowAdditionsReference/DOMWindowAdditions/DOMWindowAdditions.html
_DomPoint _convertPointFromNodeToPage(Node node, _DomPoint p) native;
@JSName('webkitConvertPointFromPageToNode')
@DomName('Window.webkitConvertPointFromPageToNode')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
// http://developer.apple.com/library/safari/#documentation/DataManagement/Reference/DOMWindowAdditionsReference/DOMWindowAdditions/DOMWindowAdditions.html
_DomPoint _convertPointFromPageToNode(Node node, _DomPoint p) native;
@JSName('webkitRequestFileSystem')
@DomName('Window.webkitRequestFileSystem')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@Experimental
// http://www.w3.org/TR/file-system-api/#idl-def-LocalFileSystem
void __requestFileSystem(int type, int size, _FileSystemCallback successCallback, [_ErrorCallback errorCallback]) native;
@JSName('webkitRequestFileSystem')
@DomName('Window.webkitRequestFileSystem')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@Experimental
// http://www.w3.org/TR/file-system-api/#idl-def-LocalFileSystem
Future<FileSystem> _requestFileSystem(int type, int size) {
var completer = new Completer<FileSystem>();
__requestFileSystem(type, size,
(value) { completer.complete(value); },
(error) { completer.completeError(error); });
return completer.future;
}
@JSName('webkitResolveLocalFileSystemURL')
@DomName('Window.webkitResolveLocalFileSystemURL')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@Experimental
// http://www.w3.org/TR/file-system-api/#idl-def-LocalFileSystem
void _resolveLocalFileSystemUrl(String url, _EntryCallback successCallback, [_ErrorCallback errorCallback]) native;
@JSName('webkitResolveLocalFileSystemURL')
@DomName('Window.webkitResolveLocalFileSystemURL')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@Experimental
// http://www.w3.org/TR/file-system-api/#idl-def-LocalFileSystem
Future<Entry> resolveLocalFileSystemUrl(String url) {
var completer = new Completer<Entry>();
_resolveLocalFileSystemUrl(url,
(value) { completer.complete(value); },
(error) { completer.completeError(error); });
return completer.future;
}
@DomName('Window.onDOMContentLoaded')
@DocsEditable
Stream<Event> get onContentLoaded => contentLoadedEvent.forTarget(this);
@DomName('Window.onabort')
@DocsEditable
Stream<Event> get onAbort => Element.abortEvent.forTarget(this);
@DomName('Window.onblur')
@DocsEditable
Stream<Event> get onBlur => Element.blurEvent.forTarget(this);
@DomName('Window.onchange')
@DocsEditable
Stream<Event> get onChange => Element.changeEvent.forTarget(this);
@DomName('Window.onclick')
@DocsEditable
Stream<MouseEvent> get onClick => Element.clickEvent.forTarget(this);
@DomName('Window.oncontextmenu')
@DocsEditable
Stream<MouseEvent> get onContextMenu => Element.contextMenuEvent.forTarget(this);
@DomName('Window.ondblclick')
@DocsEditable
Stream<Event> get onDoubleClick => Element.doubleClickEvent.forTarget(this);
@DomName('Window.ondevicemotion')
@DocsEditable
// http://dev.w3.org/geo/api/spec-source-orientation.html#devicemotion
@Experimental
Stream<DeviceMotionEvent> get onDeviceMotion => deviceMotionEvent.forTarget(this);
@DomName('Window.ondeviceorientation')
@DocsEditable
// http://dev.w3.org/geo/api/spec-source-orientation.html#devicemotion
@Experimental
Stream<DeviceOrientationEvent> get onDeviceOrientation => deviceOrientationEvent.forTarget(this);
@DomName('Window.ondrag')
@DocsEditable
Stream<MouseEvent> get onDrag => Element.dragEvent.forTarget(this);
@DomName('Window.ondragend')
@DocsEditable
Stream<MouseEvent> get onDragEnd => Element.dragEndEvent.forTarget(this);
@DomName('Window.ondragenter')
@DocsEditable
Stream<MouseEvent> get onDragEnter => Element.dragEnterEvent.forTarget(this);
@DomName('Window.ondragleave')
@DocsEditable
Stream<MouseEvent> get onDragLeave => Element.dragLeaveEvent.forTarget(this);
@DomName('Window.ondragover')
@DocsEditable
Stream<MouseEvent> get onDragOver => Element.dragOverEvent.forTarget(this);
@DomName('Window.ondragstart')
@DocsEditable
Stream<MouseEvent> get onDragStart => Element.dragStartEvent.forTarget(this);
@DomName('Window.ondrop')
@DocsEditable
Stream<MouseEvent> get onDrop => Element.dropEvent.forTarget(this);
@DomName('Window.onerror')
@DocsEditable
Stream<Event> get onError => Element.errorEvent.forTarget(this);
@DomName('Window.onfocus')
@DocsEditable
Stream<Event> get onFocus => Element.focusEvent.forTarget(this);
@DomName('Window.onhashchange')
@DocsEditable
Stream<Event> get onHashChange => hashChangeEvent.forTarget(this);
@DomName('Window.oninput')
@DocsEditable
Stream<Event> get onInput => Element.inputEvent.forTarget(this);
@DomName('Window.oninvalid')
@DocsEditable
Stream<Event> get onInvalid => Element.invalidEvent.forTarget(this);
@DomName('Window.onkeydown')
@DocsEditable
Stream<KeyboardEvent> get onKeyDown => Element.keyDownEvent.forTarget(this);
@DomName('Window.onkeypress')
@DocsEditable
Stream<KeyboardEvent> get onKeyPress => Element.keyPressEvent.forTarget(this);
@DomName('Window.onkeyup')
@DocsEditable
Stream<KeyboardEvent> get onKeyUp => Element.keyUpEvent.forTarget(this);
@DomName('Window.onload')
@DocsEditable
Stream<Event> get onLoad => Element.loadEvent.forTarget(this);
@DomName('Window.onmessage')
@DocsEditable
Stream<MessageEvent> get onMessage => messageEvent.forTarget(this);
@DomName('Window.onmousedown')
@DocsEditable
Stream<MouseEvent> get onMouseDown => Element.mouseDownEvent.forTarget(this);
@DomName('Window.onmousemove')
@DocsEditable
Stream<MouseEvent> get onMouseMove => Element.mouseMoveEvent.forTarget(this);
@DomName('Window.onmouseout')
@DocsEditable
Stream<MouseEvent> get onMouseOut => Element.mouseOutEvent.forTarget(this);
@DomName('Window.onmouseover')
@DocsEditable
Stream<MouseEvent> get onMouseOver => Element.mouseOverEvent.forTarget(this);
@DomName('Window.onmouseup')
@DocsEditable
Stream<MouseEvent> get onMouseUp => Element.mouseUpEvent.forTarget(this);
@DomName('Window.onmousewheel')
@DocsEditable
Stream<WheelEvent> get onMouseWheel => Element.mouseWheelEvent.forTarget(this);
@DomName('Window.onoffline')
@DocsEditable
Stream<Event> get onOffline => offlineEvent.forTarget(this);
@DomName('Window.ononline')
@DocsEditable
Stream<Event> get onOnline => onlineEvent.forTarget(this);
@DomName('Window.onpagehide')
@DocsEditable
Stream<Event> get onPageHide => pageHideEvent.forTarget(this);
@DomName('Window.onpageshow')
@DocsEditable
Stream<Event> get onPageShow => pageShowEvent.forTarget(this);
@DomName('Window.onpopstate')
@DocsEditable
Stream<PopStateEvent> get onPopState => popStateEvent.forTarget(this);
@DomName('Window.onreset')
@DocsEditable
Stream<Event> get onReset => Element.resetEvent.forTarget(this);
@DomName('Window.onresize')
@DocsEditable
Stream<Event> get onResize => resizeEvent.forTarget(this);
@DomName('Window.onscroll')
@DocsEditable
Stream<Event> get onScroll => Element.scrollEvent.forTarget(this);
@DomName('Window.onsearch')
@DocsEditable
// http://www.w3.org/TR/html-markup/input.search.html
@Experimental
Stream<Event> get onSearch => Element.searchEvent.forTarget(this);
@DomName('Window.onselect')
@DocsEditable
Stream<Event> get onSelect => Element.selectEvent.forTarget(this);
@DomName('Window.onstorage')
@DocsEditable
Stream<StorageEvent> get onStorage => storageEvent.forTarget(this);
@DomName('Window.onsubmit')
@DocsEditable
Stream<Event> get onSubmit => Element.submitEvent.forTarget(this);
@DomName('Window.ontouchcancel')
@DocsEditable
// http://www.w3.org/TR/touch-events/, http://www.chromestatus.com/features
@Experimental
Stream<TouchEvent> get onTouchCancel => Element.touchCancelEvent.forTarget(this);
@DomName('Window.ontouchend')
@DocsEditable
// http://www.w3.org/TR/touch-events/, http://www.chromestatus.com/features
@Experimental
Stream<TouchEvent> get onTouchEnd => Element.touchEndEvent.forTarget(this);
@DomName('Window.ontouchmove')
@DocsEditable
// http://www.w3.org/TR/touch-events/, http://www.chromestatus.com/features
@Experimental
Stream<TouchEvent> get onTouchMove => Element.touchMoveEvent.forTarget(this);
@DomName('Window.ontouchstart')
@DocsEditable
// http://www.w3.org/TR/touch-events/, http://www.chromestatus.com/features
@Experimental
Stream<TouchEvent> get onTouchStart => Element.touchStartEvent.forTarget(this);
@DomName('Window.ontransitionend')
@DocsEditable
Stream<TransitionEvent> get onTransitionEnd => Element.transitionEndEvent.forTarget(this);
@DomName('Window.onunload')
@DocsEditable
Stream<Event> get onUnload => unloadEvent.forTarget(this);
@DomName('Window.onwebkitAnimationEnd')
@DocsEditable
@Experimental
Stream<AnimationEvent> get onAnimationEnd => animationEndEvent.forTarget(this);
@DomName('Window.onwebkitAnimationIteration')
@DocsEditable
@Experimental
Stream<AnimationEvent> get onAnimationIteration => animationIterationEvent.forTarget(this);
@DomName('Window.onwebkitAnimationStart')
@DocsEditable
@Experimental
Stream<AnimationEvent> get onAnimationStart => animationStartEvent.forTarget(this);
@DomName('DOMWindow.beforeunloadEvent')
@DocsEditable
static const EventStreamProvider<BeforeUnloadEvent> beforeUnloadEvent =
const _BeforeUnloadEventStreamProvider('beforeunload');
@DomName('DOMWindow.onbeforeunload')
@DocsEditable
Stream<Event> get onBeforeUnload => beforeUnloadEvent.forTarget(this);
}
Extends
Interceptor > EventTarget > Window
Implements
Static Properties
const EventStreamProvider<AnimationEvent> animationEndEvent #
static const EventStreamProvider<AnimationEvent> animationEndEvent = const EventStreamProvider<AnimationEvent>('webkitAnimationEnd')
const EventStreamProvider<AnimationEvent> animationIterationEvent #
static const EventStreamProvider<AnimationEvent> animationIterationEvent = const EventStreamProvider<AnimationEvent>('webkitAnimationIteration')
const EventStreamProvider<AnimationEvent> animationStartEvent #
static const EventStreamProvider<AnimationEvent> animationStartEvent = const EventStreamProvider<AnimationEvent>('webkitAnimationStart')
const EventStreamProvider<BeforeUnloadEvent> beforeUnloadEvent #
static const EventStreamProvider<BeforeUnloadEvent> beforeUnloadEvent =
const _BeforeUnloadEventStreamProvider('beforeunload')
const EventStreamProvider<Event> contentLoadedEvent #
static const EventStreamProvider<Event> contentLoadedEvent = const EventStreamProvider<Event>('DOMContentLoaded')
const EventStreamProvider<DeviceMotionEvent> deviceMotionEvent #
static const EventStreamProvider<DeviceMotionEvent> deviceMotionEvent = const EventStreamProvider<DeviceMotionEvent>('devicemotion')
const EventStreamProvider<DeviceOrientationEvent> deviceOrientationEvent #
static const EventStreamProvider<DeviceOrientationEvent> deviceOrientationEvent = const EventStreamProvider<DeviceOrientationEvent>('deviceorientation')
const EventStreamProvider<Event> hashChangeEvent #
static const EventStreamProvider<Event> hashChangeEvent = const EventStreamProvider<Event>('hashchange')
const EventStreamProvider<MessageEvent> messageEvent #
static const EventStreamProvider<MessageEvent> messageEvent = const EventStreamProvider<MessageEvent>('message')
const EventStreamProvider<Event> offlineEvent #
static const EventStreamProvider<Event> offlineEvent = const EventStreamProvider<Event>('offline')
const EventStreamProvider<Event> onlineEvent #
static const EventStreamProvider<Event> onlineEvent = const EventStreamProvider<Event>('online')
const EventStreamProvider<Event> pageHideEvent #
static const EventStreamProvider<Event> pageHideEvent = const EventStreamProvider<Event>('pagehide')
const EventStreamProvider<Event> pageShowEvent #
static const EventStreamProvider<Event> pageShowEvent = const EventStreamProvider<Event>('pageshow')
const EventStreamProvider<PopStateEvent> popStateEvent #
static const EventStreamProvider<PopStateEvent> popStateEvent = const EventStreamProvider<PopStateEvent>('popstate')
const EventStreamProvider<Event> resizeEvent #
static const EventStreamProvider<Event> resizeEvent = const EventStreamProvider<Event>('resize')
const EventStreamProvider<StorageEvent> storageEvent #
static const EventStreamProvider<StorageEvent> storageEvent = const EventStreamProvider<StorageEvent>('storage')
final bool supportsPointConversions #
Checks whether convertPointFromNodeToPage and convertPointFromPageToNode are supported on the current platform.
static bool get supportsPointConversions => _DomPoint.supported;
const EventStreamProvider<Event> unloadEvent #
static const EventStreamProvider<Event> unloadEvent = const EventStreamProvider<Event>('unload')
Properties
final Future<num> animationFrame #
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.
Future<num> get animationFrame {
var completer = new Completer<num>();
requestAnimationFrame((time) {
completer.complete(time);
});
return completer.future;
}
final ApplicationCache applicationCache #
final ApplicationCache applicationCache
final bool closed #
Indicates whether this window has been closed.
print(window.closed); // 'false'
window.close();
print(window.closed); // 'true'
final bool closed
final int hashCode #
Get a hash code for this object.
All objects have hash codes. Hash codes are guaranteed to be the
same for objects that are equal when compared using the equality
operator ==. Other than that there are no guarantees about
the hash codes. They will not be consistent between runs and
there are no distribution guarantees.
If a subclass overrides hashCode it should override the
equality operator as well to maintain consistency.
int get hashCode => Primitives.objectHashCode(this);
final IdbFactory indexedDB #
Gets an instance of the Indexed DB factory to being using Indexed DB.
Use IdbFactory.supported to check if Indexed DB is supported on the
current platform.
@SupportedBrowser(SupportedBrowser.CHROME, '23.0')
@SupportedBrowser(SupportedBrowser.FIREFOX, '15.0')
@SupportedBrowser(SupportedBrowser.IE, '10.0')
@Experimental
IdbFactory get indexedDB =>
JS('IdbFactory|Null', // If not supported, returns `null`.
'#.indexedDB || #.webkitIndexedDB || #.mozIndexedDB',
this, this, this);
Location get location #
The current location of this window.
Location currentLocation = window.location;
print(currentLocation.href); // 'http://www.example.com:80/'
Location get location {
// Firefox work-around for Location. The Firefox location object cannot be
// made to behave like a Dart object so must be wrapped.
var result = _location;
if (_isDartLocation(result)) return result; // e.g. on Chrome.
if (null == _location_wrapper) {
_location_wrapper = new _LocationWrapper(result);
}
return _location_wrapper;
}
void set location(value) #
Sets the window's location, which causes the browser to navigate to the new location. value may be a Location object or a string.
void set location(value) {
if (value is _LocationWrapper) {
_location = value._ptr;
} else {
_location = value;
}
}
final NotificationCenter notifications #
final NotificationCenter notifications
final Events on #
This is an ease-of-use accessor for event streams which should only be used when an explicit accessor is not available.
Events get on => new Events(this);
final Stream<Event> onAbort #
@DomName('Window.onabort')
@DocsEditable
Stream<Event> get onAbort => Element.abortEvent.forTarget(this);
final Stream<AnimationEvent> onAnimationEnd #
@DomName('Window.onwebkitAnimationEnd')
@DocsEditable
@Experimental
Stream<AnimationEvent> get onAnimationEnd => animationEndEvent.forTarget(this);
final Stream<AnimationEvent> onAnimationIteration #
@DomName('Window.onwebkitAnimationIteration')
@DocsEditable
@Experimental
Stream<AnimationEvent> get onAnimationIteration => animationIterationEvent.forTarget(this);
final Stream<AnimationEvent> onAnimationStart #
@DomName('Window.onwebkitAnimationStart')
@DocsEditable
@Experimental
Stream<AnimationEvent> get onAnimationStart => animationStartEvent.forTarget(this);
final Stream<Event> onBeforeUnload #
@DomName('DOMWindow.onbeforeunload')
@DocsEditable
Stream<Event> get onBeforeUnload => beforeUnloadEvent.forTarget(this);
final Stream<Event> onBlur #
@DomName('Window.onblur')
@DocsEditable
Stream<Event> get onBlur => Element.blurEvent.forTarget(this);
final Stream<Event> onChange #
@DomName('Window.onchange')
@DocsEditable
Stream<Event> get onChange => Element.changeEvent.forTarget(this);
final Stream<MouseEvent> onClick #
@DomName('Window.onclick')
@DocsEditable
Stream<MouseEvent> get onClick => Element.clickEvent.forTarget(this);
final Stream<Event> onContentLoaded #
@DomName('Window.onDOMContentLoaded')
@DocsEditable
Stream<Event> get onContentLoaded => contentLoadedEvent.forTarget(this);
final Stream<MouseEvent> onContextMenu #
@DomName('Window.oncontextmenu')
@DocsEditable
Stream<MouseEvent> get onContextMenu => Element.contextMenuEvent.forTarget(this);
final Stream<DeviceMotionEvent> onDeviceMotion #
@DomName('Window.ondevicemotion')
@DocsEditable
// http://dev.w3.org/geo/api/spec-source-orientation.html#devicemotion
@Experimental
Stream<DeviceMotionEvent> get onDeviceMotion => deviceMotionEvent.forTarget(this);
final Stream<DeviceOrientationEvent> onDeviceOrientation #
@DomName('Window.ondeviceorientation')
@DocsEditable
// http://dev.w3.org/geo/api/spec-source-orientation.html#devicemotion
@Experimental
Stream<DeviceOrientationEvent> get onDeviceOrientation => deviceOrientationEvent.forTarget(this);
final Stream<Event> onDoubleClick #
@DomName('Window.ondblclick')
@DocsEditable
Stream<Event> get onDoubleClick => Element.doubleClickEvent.forTarget(this);
final Stream<MouseEvent> onDrag #
@DomName('Window.ondrag')
@DocsEditable
Stream<MouseEvent> get onDrag => Element.dragEvent.forTarget(this);
final Stream<MouseEvent> onDragEnd #
@DomName('Window.ondragend')
@DocsEditable
Stream<MouseEvent> get onDragEnd => Element.dragEndEvent.forTarget(this);
final Stream<MouseEvent> onDragEnter #
@DomName('Window.ondragenter')
@DocsEditable
Stream<MouseEvent> get onDragEnter => Element.dragEnterEvent.forTarget(this);
final Stream<MouseEvent> onDragLeave #
@DomName('Window.ondragleave')
@DocsEditable
Stream<MouseEvent> get onDragLeave => Element.dragLeaveEvent.forTarget(this);
final Stream<MouseEvent> onDragOver #
@DomName('Window.ondragover')
@DocsEditable
Stream<MouseEvent> get onDragOver => Element.dragOverEvent.forTarget(this);
final Stream<MouseEvent> onDragStart #
@DomName('Window.ondragstart')
@DocsEditable
Stream<MouseEvent> get onDragStart => Element.dragStartEvent.forTarget(this);
final Stream<MouseEvent> onDrop #
@DomName('Window.ondrop')
@DocsEditable
Stream<MouseEvent> get onDrop => Element.dropEvent.forTarget(this);
final Stream<Event> onError #
@DomName('Window.onerror')
@DocsEditable
Stream<Event> get onError => Element.errorEvent.forTarget(this);
final Stream<Event> onFocus #
@DomName('Window.onfocus')
@DocsEditable
Stream<Event> get onFocus => Element.focusEvent.forTarget(this);
final Stream<Event> onHashChange #
@DomName('Window.onhashchange')
@DocsEditable
Stream<Event> get onHashChange => hashChangeEvent.forTarget(this);
final Stream<Event> onInput #
@DomName('Window.oninput')
@DocsEditable
Stream<Event> get onInput => Element.inputEvent.forTarget(this);
final Stream<Event> onInvalid #
@DomName('Window.oninvalid')
@DocsEditable
Stream<Event> get onInvalid => Element.invalidEvent.forTarget(this);
final Stream<KeyboardEvent> onKeyDown #
@DomName('Window.onkeydown')
@DocsEditable
Stream<KeyboardEvent> get onKeyDown => Element.keyDownEvent.forTarget(this);
final Stream<KeyboardEvent> onKeyPress #
@DomName('Window.onkeypress')
@DocsEditable
Stream<KeyboardEvent> get onKeyPress => Element.keyPressEvent.forTarget(this);
final Stream<KeyboardEvent> onKeyUp #
@DomName('Window.onkeyup')
@DocsEditable
Stream<KeyboardEvent> get onKeyUp => Element.keyUpEvent.forTarget(this);
final Stream<Event> onLoad #
@DomName('Window.onload')
@DocsEditable
Stream<Event> get onLoad => Element.loadEvent.forTarget(this);
final Stream<MessageEvent> onMessage #
@DomName('Window.onmessage')
@DocsEditable
Stream<MessageEvent> get onMessage => messageEvent.forTarget(this);
final Stream<MouseEvent> onMouseDown #
@DomName('Window.onmousedown')
@DocsEditable
Stream<MouseEvent> get onMouseDown => Element.mouseDownEvent.forTarget(this);
final Stream<MouseEvent> onMouseMove #
@DomName('Window.onmousemove')
@DocsEditable
Stream<MouseEvent> get onMouseMove => Element.mouseMoveEvent.forTarget(this);
final Stream<MouseEvent> onMouseOut #
@DomName('Window.onmouseout')
@DocsEditable
Stream<MouseEvent> get onMouseOut => Element.mouseOutEvent.forTarget(this);
final Stream<MouseEvent> onMouseOver #
@DomName('Window.onmouseover')
@DocsEditable
Stream<MouseEvent> get onMouseOver => Element.mouseOverEvent.forTarget(this);
final Stream<MouseEvent> onMouseUp #
@DomName('Window.onmouseup')
@DocsEditable
Stream<MouseEvent> get onMouseUp => Element.mouseUpEvent.forTarget(this);
final Stream<WheelEvent> onMouseWheel #
@DomName('Window.onmousewheel')
@DocsEditable
Stream<WheelEvent> get onMouseWheel => Element.mouseWheelEvent.forTarget(this);
final Stream<Event> onOffline #
@DomName('Window.onoffline')
@DocsEditable
Stream<Event> get onOffline => offlineEvent.forTarget(this);
final Stream<Event> onOnline #
@DomName('Window.ononline')
@DocsEditable
Stream<Event> get onOnline => onlineEvent.forTarget(this);
final Stream<Event> onPageHide #
@DomName('Window.onpagehide')
@DocsEditable
Stream<Event> get onPageHide => pageHideEvent.forTarget(this);
final Stream<Event> onPageShow #
@DomName('Window.onpageshow')
@DocsEditable
Stream<Event> get onPageShow => pageShowEvent.forTarget(this);
final Stream<PopStateEvent> onPopState #
@DomName('Window.onpopstate')
@DocsEditable
Stream<PopStateEvent> get onPopState => popStateEvent.forTarget(this);
final Stream<Event> onReset #
@DomName('Window.onreset')
@DocsEditable
Stream<Event> get onReset => Element.resetEvent.forTarget(this);
final Stream<Event> onResize #
@DomName('Window.onresize')
@DocsEditable
Stream<Event> get onResize => resizeEvent.forTarget(this);
final Stream<Event> onScroll #
@DomName('Window.onscroll')
@DocsEditable
Stream<Event> get onScroll => Element.scrollEvent.forTarget(this);
final Stream<Event> onSearch #
@DomName('Window.onsearch')
@DocsEditable
// http://www.w3.org/TR/html-markup/input.search.html
@Experimental
Stream<Event> get onSearch => Element.searchEvent.forTarget(this);
final Stream<Event> onSelect #
@DomName('Window.onselect')
@DocsEditable
Stream<Event> get onSelect => Element.selectEvent.forTarget(this);
final Stream<StorageEvent> onStorage #
@DomName('Window.onstorage')
@DocsEditable
Stream<StorageEvent> get onStorage => storageEvent.forTarget(this);
final Stream<Event> onSubmit #
@DomName('Window.onsubmit')
@DocsEditable
Stream<Event> get onSubmit => Element.submitEvent.forTarget(this);
final Stream<TouchEvent> onTouchCancel #
@DomName('Window.ontouchcancel')
@DocsEditable
// http://www.w3.org/TR/touch-events/, http://www.chromestatus.com/features
@Experimental
Stream<TouchEvent> get onTouchCancel => Element.touchCancelEvent.forTarget(this);
final Stream<TouchEvent> onTouchEnd #
@DomName('Window.ontouchend')
@DocsEditable
// http://www.w3.org/TR/touch-events/, http://www.chromestatus.com/features
@Experimental
Stream<TouchEvent> get onTouchEnd => Element.touchEndEvent.forTarget(this);
final Stream<TouchEvent> onTouchMove #
@DomName('Window.ontouchmove')
@DocsEditable
// http://www.w3.org/TR/touch-events/, http://www.chromestatus.com/features
@Experimental
Stream<TouchEvent> get onTouchMove => Element.touchMoveEvent.forTarget(this);
final Stream<TouchEvent> onTouchStart #
@DomName('Window.ontouchstart')
@DocsEditable
// http://www.w3.org/TR/touch-events/, http://www.chromestatus.com/features
@Experimental
Stream<TouchEvent> get onTouchStart => Element.touchStartEvent.forTarget(this);
final Stream<TransitionEvent> onTransitionEnd #
@DomName('Window.ontransitionend')
@DocsEditable
Stream<TransitionEvent> get onTransitionEnd => Element.transitionEndEvent.forTarget(this);
final Stream<Event> onUnload #
@DomName('Window.onunload')
@DocsEditable
Stream<Event> get onUnload => unloadEvent.forTarget(this);
final WindowBase opener #
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'
WindowBase get opener => _convertNativeToDart_Window(this._get_opener);
final WindowBase parent #
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'
WindowBase get parent => _convertNativeToDart_Window(this._get_parent);
final Performance performance #
final Performance performance
final Type runtimeType #
A representation of the runtime type of the object.
Type get runtimeType => getRuntimeType(this);
final WindowBase self #
WindowBase get self => _convertNativeToDart_Window(this._get_self);
final SpeechSynthesis speechSynthesis #
final SpeechSynthesis speechSynthesis
final StorageInfo storageInfo #
final StorageInfo storageInfo
final StyleMedia styleMedia #
final StyleMedia styleMedia
final WindowBase top #
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'
WindowBase get top => _convertNativeToDart_Window(this._get_top);
final WindowBase window #
WindowBase get window => _convertNativeToDart_Window(this._get_window);
Operators
bool operator ==(other) #
The equality operator.
The default behavior for all Objects is to return true if and
only if this and
other are the same object.
If a subclass overrides the equality operator it should override
the hashCode method as well to maintain consistency.
bool operator ==(other) => identical(this, other);
Methods
void alert(String message) #
@DomName('Window.alert')
@DocsEditable
void alert(String message) native;
String atob(String string) #
@DomName('Window.atob')
@DocsEditable
String atob(String string) native;
String btoa(String string) #
@DomName('Window.btoa')
@DocsEditable
String btoa(String string) native;
void cancelAnimationFrame(int id) #
void cancelAnimationFrame(int id) {
_ensureRequestAnimationFrame();
_cancelAnimationFrame(id);
}
void close() #
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'
window.location('http://www.mysite.com', 'foo');
// Does not close this window, as the history has changed.
window.close();
print(window.closed()); // 'false'
See also:
- Window close discussion from the W3C
@DomName('Window.close')
@DocsEditable
void close() native;
bool confirm(String message) #
@DomName('Window.confirm')
@DocsEditable
bool confirm(String message) native;
Point convertPointFromNodeToPage(Node node, Point point) #
@DomName('DOMWindow.convertPointFromNodeToPage')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
Point convertPointFromNodeToPage(Node node, Point point) {
var result = _convertPointFromNodeToPage(node,
new _DomPoint(point.x, point.y));
return new Point(result.x, result.y);
}
Point convertPointFromPageToNode(Node node, Point point) #
@DomName('DOMWindow.convertPointFromPageToNode')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
Point convertPointFromPageToNode(Node node, Point point) {
var result = _convertPointFromPageToNode(node,
new _DomPoint(point.x, point.y));
return new Point(result.x, result.y);
}
bool dispatchEvent(Event evt) #
@DomName('Window.dispatchEvent')
@DocsEditable
bool dispatchEvent(Event evt) native;
bool find(String string, bool caseSensitive, bool backwards, bool wrap, bool wholeWord, bool searchInFrames, bool showDialog) #
@DomName('Window.find')
@DocsEditable
@Experimental // non-standard
bool find(String string, bool caseSensitive, bool backwards, bool wrap, bool wholeWord, bool searchInFrames, bool showDialog) native;
List<CssRule> getMatchedCssRules(Element element, String pseudoElement) #
@JSName('getMatchedCSSRules')
@DomName('Window.getMatchedCSSRules')
@DocsEditable
@Experimental // non-standard
@Returns('_CssRuleList')
@Creates('_CssRuleList')
List<CssRule> getMatchedCssRules(Element element, String pseudoElement) native;
Selection getSelection() #
@DomName('Window.getSelection')
@DocsEditable
Selection getSelection() native;
SendPortSync lookupPort(String name) #
Lookup a port by its name. Return null if no port is registered under name.
SendPortSync lookupPort(String name) {
var portStr = document.documentElement.attributes['dart-port:$name'];
if (portStr == null) {
return null;
}
var port = json.parse(portStr);
return _deserialize(port);
}
MediaQueryList matchMedia(String query) #
@DomName('Window.matchMedia')
@DocsEditable
MediaQueryList matchMedia(String query) native;
void moveBy(num x, num y) #
@DomName('Window.moveBy')
@DocsEditable
void moveBy(num x, num y) native;
void moveTo(num x, num y) #
@DomName('Window.moveTo')
@DocsEditable
void moveTo(num x, num y) native;
dynamic noSuchMethod(Invocation invocation) #
noSuchMethod is invoked when users invoke a non-existant method
on an object. The name of the method and the arguments of the
invocation are passed to noSuchMethod in an Invocation.
If noSuchMethod returns a value, that value becomes the result of
the original invocation.
The default behavior of noSuchMethod is to throw a
noSuchMethodError.
dynamic noSuchMethod(Invocation invocation) {
throw new NoSuchMethodError(
this,
_symbolToString(invocation.memberName),
invocation.positionalArguments,
_symbolMapToStringMap(invocation.namedArguments));
}
WindowBase open(String url, String name, [String options]) #
WindowBase open(String url, String name, [String options]) {
if (options == null) {
return _DOMWindowCrossFrame._createSafe(_open2(url, name));
} else {
return _DOMWindowCrossFrame._createSafe(_open3(url, name, options));
}
}
SqlDatabase openDatabase(String name, String version, String displayName, int estimatedSize, [DatabaseCallback creationCallback]) #
@DomName('Window.openDatabase')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
// http://www.w3.org/TR/webdatabase/
@Experimental // deprecated
@Creates('SqlDatabase')
SqlDatabase openDatabase(String name, String version, String displayName, int estimatedSize, [DatabaseCallback creationCallback]) native;
void postMessage(message, String targetOrigin, [List messagePorts]) #
@DomName('Window.postMessage')
@DocsEditable
void postMessage(/*SerializedScriptValue*/ message, String targetOrigin, [List messagePorts]) {
if (messagePorts != null) {
var message_1 = convertDartToNative_SerializedScriptValue(message);
_postMessage_1(message_1, targetOrigin, messagePorts);
return;
}
var message_2 = convertDartToNative_SerializedScriptValue(message);
_postMessage_2(message_2, targetOrigin);
return;
}
void print() #
@DomName('Window.print')
@DocsEditable
void print() native;
void registerPort(String name, port) #
Register a port on this window under the given name. This port may be retrieved by any isolate (or JavaScript script) running in this window.
void registerPort(String name, var port) {
var serialized = _serialize(port);
document.documentElement.attributes['dart-port:$name'] =
json.stringify(serialized);
}
int requestAnimationFrame(RequestAnimationFrameCallback callback) #
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.
@DomName('DOMWindow.requestAnimationFrame')
int requestAnimationFrame(RequestAnimationFrameCallback callback) {
_ensureRequestAnimationFrame();
return _requestAnimationFrame(callback);
}
Future<FileSystem> requestFileSystem(int size, {bool persistent: false}) #
Access a sandboxed file system of the specified size. 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.
Future<FileSystem> requestFileSystem(int size, {bool persistent: false}) {
return _requestFileSystem(persistent? 1 : 0, size);
}
void resizeBy(num x, num y) #
@DomName('Window.resizeBy')
@DocsEditable
void resizeBy(num x, num y) native;
void resizeTo(num width, num height) #
@DomName('Window.resizeTo')
@DocsEditable
void resizeTo(num width, num height) native;
Future<Entry> resolveLocalFileSystemUrl(String url) #
@JSName('webkitResolveLocalFileSystemURL')
@DomName('Window.webkitResolveLocalFileSystemURL')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@Experimental
// http://www.w3.org/TR/file-system-api/#idl-def-LocalFileSystem
Future<Entry> resolveLocalFileSystemUrl(String url) {
var completer = new Completer<Entry>();
_resolveLocalFileSystemUrl(url,
(value) { completer.complete(value); },
(error) { completer.completeError(error); });
return completer.future;
}
void scroll(int x, int y) #
@DomName('Window.scroll')
@DocsEditable
void scroll(int x, int y) native;
void scrollBy(int x, int y) #
@DomName('Window.scrollBy')
@DocsEditable
void scrollBy(int x, int y) native;
void scrollTo(int x, int y) #
@DomName('Window.scrollTo')
@DocsEditable
void scrollTo(int x, int y) native;
void setImmediate(TimeoutHandler callback) #
Executes a callback after the immediate execution stack has completed.
This differs from using Timer.run(callback) because Timer will run in about 4-15 milliseconds, depending on browser, depending on load. setImmediate, in contrast, makes browser-specific changes in behavior to attempt to run immediately after the current frame unwinds, causing the future to complete after all processing has completed for the current event, but before any subsequent events.
void setImmediate(TimeoutHandler callback) {
_addMicrotaskCallback(callback);
}
Object showModalDialog(String url, [Object dialogArgs, String featureArgs]) #
@DomName('Window.showModalDialog')
@DocsEditable
@Creates('Null')
Object showModalDialog(String url, [Object dialogArgs, String featureArgs]) native;
void stop() #
@DomName('Window.stop')
@DocsEditable
void stop() native;
String toString() #
Returns a string representation of this object.
@DomName('Window.toString')
@DocsEditable
String toString() native;
void $dom_addEventListener(String type, EventListener listener, [bool useCapture]) #
@JSName('addEventListener')
@DomName('Window.addEventListener')
@DocsEditable
void $dom_addEventListener(String type, EventListener listener, [bool useCapture]) native;
CssStyleDeclaration $dom_getComputedStyle(Element element, String pseudoElement) #
@JSName('getComputedStyle')
@DomName('Window.getComputedStyle')
@DocsEditable
CssStyleDeclaration $dom_getComputedStyle(Element element, String pseudoElement) native;
void $dom_removeEventListener(String type, EventListener listener, [bool useCapture]) #
@JSName('removeEventListener')
@DomName('Window.removeEventListener')
@DocsEditable
void $dom_removeEventListener(String type, EventListener listener, [bool useCapture]) native;
This page includes content from the
Mozilla Foundation that is graciously
licensed under a
Creative Commons: Attribution-Sharealike license.
Mozilla has no other association with Dart or dartlang.org. We
encourage you to improve the web by
contributing to
The Mozilla Developer Network.