Get to know MDN better
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
Document.currentScript プロパティは、現在処理中で、 JavaScript モジュールではないスクリプトの <script> 要素を返します。(モジュールの場合は代わりに import.meta を使用してください。)
重要なことですが、スクリプト内のコードがコールバックまたはイベントハンドラーとして呼び出されている場合は、 <script> 要素を参照しないことに注意してください。初期化時に処理されている要素のみを参照します。
HTMLScriptElement または null です。
次の例では、スクリプトが非同期で実行されているかどうかをチェックしています。
| HTML # dom-document-currentscript-dev |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2024年6月15日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.