| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 part of html; | |
| 6 | |
| 7 /** | |
| 8 * An object representing the top-level context object for web scripting. | |
| 9 * | |
| 10 * In a web browser, a [Window] object represents the actual browser window. | |
| 11 * In a multi-tabbed browser, each tab has its own [Window] object. A [Window] | |
| 12 * is the container that displays a [Document]'s content. All web scripting | |
| 13 * happens within the context of a [Window] object. | |
| 14 * | |
| 15 * **Note:** This class represents any window, whereas [Window] is | |
| 16 * used to access the properties and content of the current window. | |
| 17 * | |
| 18 * See also: | |
| 19 * | |
| 20 * * [DOM Window](https://developer.mozilla.org/en-US/docs/DOM/window) from MDN. | |
| 21 * * [Window](http://www.w3.org/TR/Window/) from the W3C. | |
| 22 */ | |
| 23 abstract class WindowBase { | |
| 24 // Fields. | |
| 25 | |
| 26 /** | |
| 27 * The current location of this window. | |
| 28 * | |
| 29 * Location currentLocation = window.location; | |
| 30 * print(currentLocation.href); // 'http://www.example.com:80/' | |
| 31 */ | |
| 32 LocationBase get location; | |
| 33 HistoryBase get history; | |
| 34 | |
| 35 /** | |
| 36 * Indicates whether this window has been closed. | |
| 37 * | |
| 38 * print(window.closed); // 'false' | |
| 39 * window.close(); | |
| 40 * print(window.closed); // 'true' | |
| 41 */ | |
| 42 bool get closed; | |
| 43 | |
| 44 /** | |
| 45 * A reference to the window that opened this one. | |
| 46 * | |
| 47 * Window thisWindow = window; | |
| 48 * WindowBase otherWindow = thisWindow.open('http://www.example.com/', 'fo
o'); | |
| 49 * print(otherWindow.opener == thisWindow); // 'true' | |
| 50 */ | |
| 51 WindowBase get opener; | |
| 52 | |
| 53 /** | |
| 54 * A reference to the parent of this window. | |
| 55 * | |
| 56 * If this [WindowBase] has no parent, [parent] will return a reference to | |
| 57 * the [WindowBase] itself. | |
| 58 * | |
| 59 * IFrameElement myIFrame = new IFrameElement(); | |
| 60 * window.document.body.elements.add(myIFrame); | |
| 61 * print(myIframe.contentWindow.parent == window) // 'true' | |
| 62 * | |
| 63 * print(window.parent == window) // 'true' | |
| 64 */ | |
| 65 WindowBase get parent; | |
| 66 | |
| 67 /** | |
| 68 * A reference to the topmost window in the window hierarchy. | |
| 69 * | |
| 70 * If this [WindowBase] is the topmost [WindowBase], [top] will return a | |
| 71 * reference to the [WindowBase] itself. | |
| 72 * | |
| 73 * // Add an IFrame to the current window. | |
| 74 * IFrameElement myIFrame = new IFrameElement(); | |
| 75 * window.document.body.elements.add(myIFrame); | |
| 76 * | |
| 77 * // Add an IFrame inside of the other IFrame. | |
| 78 * IFrameElement innerIFrame = new IFrameElement(); | |
| 79 * myIFrame.elements.add(innerIFrame); | |
| 80 * | |
| 81 * print(myIframe.contentWindow.top == window) // 'true' | |
| 82 * print(innerIFrame.contentWindow.top == window) // 'true' | |
| 83 * | |
| 84 * print(window.top == window) // 'true' | |
| 85 */ | |
| 86 WindowBase get top; | |
| 87 | |
| 88 // Methods. | |
| 89 /** | |
| 90 * Closes the window. | |
| 91 * | |
| 92 * This method should only succeed if the [WindowBase] object is | |
| 93 * **script-closeable** and the window calling [close] is allowed to navigate | |
| 94 * the window. | |
| 95 * | |
| 96 * A window is script-closeable if it is either a window | |
| 97 * that was opened by another window, or if it is a window with only one | |
| 98 * document in its history. | |
| 99 * | |
| 100 * A window might not be allowed to navigate, and therefore close, another | |
| 101 * window due to browser security features. | |
| 102 * | |
| 103 * var other = window.open('http://www.example.com', 'foo'); | |
| 104 * // Closes other window, as it is script-closeable. | |
| 105 * other.close(); | |
| 106 * print(other.closed()); // 'true' | |
| 107 * | |
| 108 * window.location('http://www.mysite.com', 'foo'); | |
| 109 * // Does not close this window, as the history has changed. | |
| 110 * window.close(); | |
| 111 * print(window.closed()); // 'false' | |
| 112 * | |
| 113 * See also: | |
| 114 * | |
| 115 * * [Window close discussion](http://www.w3.org/TR/html5/browsers.html#dom-wi
ndow-close) from the W3C | |
| 116 */ | |
| 117 void close(); | |
| 118 void postMessage(var message, String targetOrigin, [List messagePorts]); | |
| 119 } | |
| 120 | |
| 121 abstract class LocationBase { | |
| 122 void set href(String val); | |
| 123 } | |
| 124 | |
| 125 abstract class HistoryBase { | |
| 126 void back(); | |
| 127 void forward(); | |
| 128 void go(int distance); | |
| 129 } | |
| OLD | NEW |