Name
Script — an HTML <script> element
Inherits from
Node, Element
Synopsis
A Script object represents an HTML <script> element. Most of its
properties simply mirror the HTML attributes with the same name, but
text works like the textContent property inherited from Node.
Note that a <script>
will not run more than once. You cannot change the src or text property of an existing <script> element to make it run a
new script. You can set these properties on a newly created <script> element to execute a
script, however. Note, though, that a <script> tag must be inserted into a
Document in order to run. The script will be executed when src or type is set or when it is inserted into
the document, whichever comes last.
Properties
booleanasynctrueif the<script>element has anasyncattribute andfalseotherwise. See Synchronous, Asynchronous, and Deferred Scripts.stringcharsetThe character encoding of the script specified by
srcURL. This property is not normally specified, and the default is to interpret the script using the same encoding as the containing document.booleandefertrueif the<script>element has adeferattribute andfalseotherwise. See Synchronous, Asynchronous, and Deferred Scripts.stringsrcThe URL of the script to be loaded.
stringtextThe text that appears between the
<script>tag and the closing</script>tag.stringtypeThe MIME type of the scripting language. The default is “text/javascript”, and you do not need to set this property (or the HTML attribute) for ordinary ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access