この翻訳は不完全です。英語から この記事を翻訳 してください。
Window.self 読み取り専用プロパティは、WindowProxy のように、ウィンドウ自身を返します。 It can be used with dot notation on a window object (that is, window.self) or standalone (self). The advantage of the standalone notation is that a similar notation exists for non-window contexts, such as in Web Workers. By using self, you can refer to the global scope in a way that will work not only in a window context (self will resolve to window.self) but also in a worker context (self will then resolve to WorkerGlobalScope.self).
構文
var w = window.self; // w === window
例
Uses of window.self like the following could just as well be replaced by window.
if (window.parent.frames[0] != window.self) {
// このウィンドウは、一覧における一番最初のフレームではありません。
}
Furthermore, when executing in the active document of a browsing context, window is a reference to the current global object and thus all of the following are equivalent:
仕様
| 仕様 | 状態 | コメント |
|---|---|---|
| WHATWG HTML Living Standard Window.self の定義 |
現行の標準 | 最新のスナップショット HTML5.1 からの変更なし |
| HTML5.1 Window.self の定義 |
草案 | HTML5 からの変更なし |
| HTML5 Window.self の定義 |
勧告 | Window.self の定義を含む最初のスナップショット |
ブラウザー互換性
| 機能 | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| 基本サポート | (有) | (有) | (有) | (有) | (有) |
| 機能 | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| 基本サポート | (有) | (有) | (有) | (有) | (有) | (有) |
関連
- Its
Workerequivalent,WorkerGlobalScope.self.