Objet de script HTML DOM
Objet de script
L'objet Script représente un élément HTML <script>.
Accéder à un objet de script
Vous pouvez accéder à un élément <script> en utilisant getElementById() :
Exemple
var x = document.getElementById("myScript");
Conseil : Vous pouvez également accéder à un élément <script> en utilisant la collection de scripts .
Créer un objet de script
Vous pouvez créer un élément <script> en utilisant la méthode document.createElement() :
Exemple
var x = document.createElement("SCRIPT");
Propriétés de l'objet de script
Property | Description |
---|---|
async | Sets or returns whether a script should be executed asynchronously as soon as it is available |
charset | Sets or returns the value of the charset attribute of a script |
crossOrigin | Sets or returns the the CORS settings of a script |
defer | Sets or returns whether a script should be executed when the page has finished parsing |
src | Sets or returns the value of the src attribute of a script |
text | Sets or returns the contents of all the text nodes that are children of a script |
type | Sets or returns the value of the type attribute of a script |
Propriétés et événements standard
L'objet Script prend également en charge les propriétés et événements standard .
Pages connexes
Référence HTML : balise HTML <script>