HTML DOM ScriptObject


Script Object

The Script object represents an HTML <script> element.

Access a Script Object

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

var x = document.getElementById("myScript"); Try it Yourself

Create a 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

= New in HTML5.

Property Description
async Sets or returns whether the script should be executed asynchronously (once the script is available).
charset Sets or returns the value of the charset attribute of the script.
defer Sets or returns whether the script should be executed when the page has finished parsing.
src Sets or returns the value of the src attribute of the script.
text Sets or returns the content of all child text nodes of the script.
type Sets or returns the value of the type attribute of the script.

Standard Properties and Events

The Script object also supports the standardPropertiesandEvents。


Related Articles

HTML Reference Manual:The HTML <script> tag

Other Extensions