Latest web development tutorials

HTML DOM Script Object

Script Object

Script object represents an HTML <script> element.

Access Script Object

You can use getElementById () to access the <script> element:

var x = document.getElementById("myScript"); 尝试一下

Creating Script Objects

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

var x = document.createElement("SCRIPT"); 尝试一下

Script Object Properties

= HTML5 in the new property.

属性 描述
async 设置或返回是否异步执行脚本(一旦脚本可用)。
charset 设置或返回脚本的 charset 属性的值。
defer 设置或返回是否在页面完成解析时执行脚本。
src 设置或返回脚本的 src 属性的值。
text 设置或返回脚本的所有子文本节点的内容。
type 设置或返回脚本的 type 属性的值。

Standard properties and events

Script objects also supports standard attributes and events .


related articles

HTML Reference Manual: HTML <Script> tag