<script>标签的对应的dom对象

本文详细介绍了HTML5中script标签的各种属性及其作用,包括src、async、defer等,并解释了这些属性如何影响脚本的执行时机。同时,还提供了DOM接口的定义。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

script 标签用于定义客户端脚本,比如 JavaScript。
除全局属性之外有如下属性

 

  • src 定义指向包含脚本的文件的 URL(这样您就可以引用某个包含脚本的文件,而不是直接把脚本插入您的 HTML 文档中)
    async 定义脚本是否异步执行。
    defer 指示脚本不会生成任何文档内容。浏览器可继续解析并绘制页面。
    type 指定MIME类型 默认text/javascript
    charset 定义脚本中使用的字符编码。

如果 async 属性为 true,则脚本会相对于文档的其余部分异步执行,这样脚本会在页面继续解析的过程中执行。
如果 async 属性为 false,而 defer 属性为 true,则脚本会在页面完成解析后执行。
如果 async 和 defer 属性均为 false,那么脚本会立即执行,页面会在脚本执行完毕后继续解析。
提示:如果存在 src 属性,则 <script> 标签必须是空的。

Dom接口

代码:  全选  运行
interface HTMLScriptElement : HTMLElement {
           attribute DOMString src;
           attribute boolean async;
           attribute boolean defer;
           attribute DOMString type;
           attribute DOMString charset;
           attribute DOMString text;
};
来源
http://www.mhtml5.com/resources/html5%E4%B8%AD%E5%AF%B9script%E6%A0%87%E7%AD%BE%E7%9A%84%E8%A7%84%E5%AE%9A%E4%B8%8E%E8%A7%A3%E9%87%8A-2
Open *xml.html* in a text editor and write JavaScript code to convert the XML string to a HTML table as below and append it to the end of the *\<body>* element. You need to first parse the XML string into an XML DOM object using: ``` var parser = new DOMParser(); var xmlDoc = parser.parseFromString(xmlString, "text/xml"); ``` <table border="1"> <thead> <tr> <td> id </td> <td> title </td> <td> linkDocCount </td> <td> linkOccCount </td> </tr> <tr> <td> 17362 </td> <td> Kiwi </td> <td> 59 </td> <td> 60 </td> </tr> <tr> <td colspan="4"> <b> Kiwi </b> are <a href="">flightless bird</a>s endemic to <a href="">New Zealand</a> ... </td> </tr> <tr> <td> 509080 </td> <td> Kiwi (people) </td> <td> 38 </td> <td> 41 </td> </tr> <tr> <td colspan="4"> <b> Kiwi </b> is the nickname used internationally for <a href="">people from New Zealand</a> ... </td> </tr> </thead> </table> * There are useful resources listed above that might help. * The *\<definition>* element contains HTML, which you must render as HTML (clickable links and so on). Inserting the XML element into the HTML document will not work. The simplest solution is to use the *innherHTML* property to convert the contents of the *\<definition>* element to a string and then assign the result to the *innherHTML* property of an appropriate HTML element such as *\<td>* * The column names are provided in the array *attrs*. You **must not** hard code these attribute names (they must not appear anywhere in the script except in the array declaration).
03-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值