HTML DOM Script Object

Script Object

The Script object represents the HTML <script> element.

Access Script Object

You can access the <script> element by using getElementById():

var x = document.getElementById("myScript");

Try it yourself

Create Script Object

You can create a <script> element by using the document.createElement() method:

var x = document.createElement("SCRIPT");

Try it yourself

Script Object Properties

Properties Description
async Set or return whether the script should be executed asynchronously once it is available.
charset Set or return the value of the script's charset attribute.
crossOrigin Set or return the CORS settings of the script.
defer Set or return whether the script should be executed after the page has been parsed.
src Set or return the value of the script's src attribute.
text Set or return the content of all text nodes that are children of the script.
type Set or return the value of the script's type attribute.

Standard Properties and Events

Script Object Supports StandardsPropertiesAndEvents.

Related Pages

HTML Reference Manual:HTML <script> Tag