HTML-DOM - Skriptobjekt
Skriptobjekt
Das Script-Objekt repräsentiert ein HTML-<script>-Element.
Greifen Sie auf ein Skriptobjekt zu
Sie können auf ein <script>-Element zugreifen, indem Sie getElementById() verwenden:
Beispiel
var x = document.getElementById("myScript");
Tipp: Sie können auch auf ein <script>-Element zugreifen, indem Sie die scripts- Sammlung verwenden.
Erstellen Sie ein Skriptobjekt
Sie können ein <script>-Element erstellen, indem Sie die Methode document.createElement() verwenden:
Beispiel
var x = document.createElement("SCRIPT");
Eigenschaften von Skriptobjekten
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 |
Standardeigenschaften und -ereignisse
Das Skriptobjekt unterstützt auch die Standardeigenschaften und -ereignisse .
Verwandte Seiten
HTML-Referenz: HTML <script>-Tag