Objeto de script HTML DOM
Objeto de script
O objeto Script representa um elemento HTML <script>.
Acessar um objeto de script
Você pode acessar um elemento <script> usando getElementById():
Exemplo
var x = document.getElementById("myScript");
Dica: Você também pode acessar um elemento <script> usando a coleção de scripts .
Criar um objeto de script
Você pode criar um elemento <script> usando o método document.createElement():
Exemplo
var x = document.createElement("SCRIPT");
Propriedades do objeto 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 |
Propriedades e eventos padrão
O objeto Script também suporta as propriedades e eventos padrão .
Páginas relacionadas
Referência HTML: tag HTML <script>