OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of html; | 5 part of html; |
6 | 6 |
7 /** | 7 /** |
8 * An object representing the top-level context object for web scripting. | 8 * An object representing the top-level context object for web scripting. |
9 * | 9 * |
10 * In a web browser, a [Window] object represents the actual browser window. | 10 * In a web browser, a [Window] object represents the actual browser window. |
(...skipping 15 matching lines...) Expand all Loading... |
26 /** | 26 /** |
27 * The current location of this window. | 27 * The current location of this window. |
28 * | 28 * |
29 * Location currentLocation = window.location; | 29 * Location currentLocation = window.location; |
30 * print(currentLocation.href); // 'http://www.example.com:80/' | 30 * print(currentLocation.href); // 'http://www.example.com:80/' |
31 */ | 31 */ |
32 Location get location; | 32 Location get location; |
33 History get history; | 33 History get history; |
34 | 34 |
35 /** | 35 /** |
36 * Indicates whether this window is closed. | 36 * Indicates whether this window has been closed. |
37 * | 37 * |
38 * print(window.closed); // 'false' | 38 * print(window.closed); // 'false' |
39 * window.close(); | 39 * window.close(); |
40 * print(window.closed); // 'true' | 40 * print(window.closed); // 'true' |
41 */ | 41 */ |
42 bool get closed; | 42 bool get closed; |
43 | 43 |
44 /** | 44 /** |
45 * A reference to the window that opened this one. | 45 * A reference to the window that opened this one. |
46 * | 46 * |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 * myIFrame.elements.add(innerIFrame); | 79 * myIFrame.elements.add(innerIFrame); |
80 * | 80 * |
81 * print(myIframe.contentWindow.top == window) // 'true' | 81 * print(myIframe.contentWindow.top == window) // 'true' |
82 * print(innerIFrame.contentWindow.top == window) // 'true' | 82 * print(innerIFrame.contentWindow.top == window) // 'true' |
83 * | 83 * |
84 * print(window.top == window) // 'true' | 84 * print(window.top == window) // 'true' |
85 */ | 85 */ |
86 Window get top; | 86 Window get top; |
87 | 87 |
88 // Methods. | 88 // Methods. |
| 89 /** |
| 90 * Closes the window. |
| 91 * |
| 92 * This method should only succeed if the [Window] 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 */ |
89 void close(); | 117 void close(); |
90 void postMessage(var message, String targetOrigin, [List messagePorts = null])
; | 118 void postMessage(var message, String targetOrigin, [List messagePorts = null])
; |
91 } | 119 } |
92 | 120 |
93 abstract class Location { | 121 abstract class Location { |
94 void set href(String val); | 122 void set href(String val); |
95 } | 123 } |
96 | 124 |
97 abstract class History { | 125 abstract class History { |
98 void back(); | 126 void back(); |
99 void forward(); | 127 void forward(); |
100 void go(int distance); | 128 void go(int distance); |
101 } | 129 } |
OLD | NEW |