Obiekt skryptu HTML DOM
Obiekt skryptu
Obiekt Script reprezentuje element HTML <script>.
Uzyskaj dostęp do obiektu skryptu
Możesz uzyskać dostęp do elementu <script> za pomocą getElementById():
Przykład
var x = document.getElementById("myScript");
Porada: Dostęp do elementu <script> można również uzyskać za pomocą kolekcji scripts .
Utwórz obiekt skryptu
Możesz utworzyć element <script> za pomocą metody document.createElement():
Przykład
var x = document.createElement("SCRIPT");
Właściwości obiektu skryptu
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 |
Standardowe właściwości i zdarzenia
Obiekt Script obsługuje również standardowe właściwości i zdarzenia .
Powiązane strony
Odniesienie HTML: tag HTML <script>