diff options
Diffstat (limited to 'files/ja/web/api/document/currentscript/index.html')
| -rw-r--r-- | files/ja/web/api/document/currentscript/index.html | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/files/ja/web/api/document/currentscript/index.html b/files/ja/web/api/document/currentscript/index.html new file mode 100644 index 0000000000..0a7f43faee --- /dev/null +++ b/files/ja/web/api/document/currentscript/index.html @@ -0,0 +1,68 @@ +--- +title: Document.currentScript +slug: Web/API/Document/currentScript +tags: + - API + - DOM + - Document + - Property + - Reference + - プロパティ +translation_of: Web/API/Document/currentScript +--- +<p>{{APIRef("DOM")}}</p> + +<p><code><strong>Document.currentScript</strong></code> プロパティは、現在処理中で、 <a href="https://github.com/whatwg/html/issues/997">JavaScript モジュールではない</a>スクリプトの {{HTMLElement("script")}} 要素を返します。 (モジュールの場合は代わりに {{JSxRef("Statements/import%2Emeta", "import.meta")}} を使用してください。</p> + +<p>重要なことですが、スクリプト内のコードがコールバックまたはイベントハンドラーとして呼び出されている場合は、 {{HTMLElement("script")}} 要素を参照しないことに注意してください。初期化時に処理されている要素のみを参照します。</p> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox notranslate">var <var>curScriptElement</var> = <var>document</var>.currentScript; +</pre> + +<h2 id="Example" name="Example">例</h2> + +<p>次の例では、スクリプトが非同期で実行されているかどうかをチェックしています。</p> + +<pre class="brush:js notranslate">if (document.currentScript.async) { + console.log("非同期で実行中"); +} else { + console.log("同期で実行中"); +}</pre> + +<p><a href="/samples/html/currentScript.html">実際の表示を確認</a></p> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName("HTML WHATWG", "dom.html#dom-document-currentscript", "Document.currentScript")}}</td> + <td>{{Spec2("HTML WHATWG")}}</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<div>{{Compat("api.Document.currentScript")}}</div> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{JSxRef("Statements/import%2Emeta", "import.meta")}}</li> + <li>{{HTMLElement("script")}}</li> + <li>{{DOMxRef("document.onafterscriptexecute")}}</li> + <li>{{DOMxRef("document.onbeforescriptexecute")}}</li> +</ul> |
