From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/fr/web/api/document/currentscript/index.html | 118 +++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 files/fr/web/api/document/currentscript/index.html (limited to 'files/fr/web/api/document/currentscript/index.html') diff --git a/files/fr/web/api/document/currentscript/index.html b/files/fr/web/api/document/currentscript/index.html new file mode 100644 index 0000000000..68fd2e0f4b --- /dev/null +++ b/files/fr/web/api/document/currentscript/index.html @@ -0,0 +1,118 @@ +--- +title: Document.currentScript +slug: Web/API/Document/currentScript +tags: + - API + - DOM + - Propriété + - Reference + - Script +translation_of: Web/API/Document/currentScript +--- +
{{ApiRef("DOM")}}
+ +

Retourne l'élément {{HTMLElement("script")}} dont le script est en cours de traitement.

+ +

Syntaxe

+ +
var curScriptElement = document.currentScript;
+
+ +

Exemple

+ +

Cet exemple vérifie si le script s'exécute de manière asynchrone :

+ +
if (document.currentScript.async) {
+  console.log("Exécution asynchrone");
+} else {
+  console.log("Exécution synchrone");
+}
+ +

Voir l'exemple sur une page

+ +

Notes

+ +

Il est important de noter que l'élément {{HTMLElement("script")}} ne sera pas référencé si le code dans le script est appelé par une fonction de rappel ou par un gestionnaire d'événements ; seul sera référencé l'élément alors qu'il est initialement en cours d'exécution.

+ +

Spécifications

+ + + + + + + + + + + + + + + + +
SpécificationStatutCommentaire
{{SpecName("HTML WHATWG", "dom.html#dom-document-currentscript", "Document.currentScript")}}{{Spec2("HTML WHATWG")}}Définition initiale
+ +

Compatibilité navigateur

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + +
FonctionnalitéChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatChrome(29.0)}}{{CompatVersionUnknown}}{{CompatGeckoDesktop("2.0")}}{{CompatNo}}168
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
FonctionnalitéAndroidChrome for AndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support4.4{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatUnknown}}8
+
+ +

Voir aussi

+ + -- cgit v1.2.3-54-g00ecf