JavaScript: The Definitive Guide, Sixth Editio javaScript权威指南(第6版) pdf 文字版-文字版, javascript电子书, 和javascript 有关的电子书:

13.2.2 Scripts in External Files

13.2.2 Scripts in External Files


A JavaScript file contains pure JavaScript, without tags. Note that the closingtag is required in HTML documents even when the src attribute is specified, and there is no content between the tags. In XHTML, you can use the shortcuttag in this case.

When you use the src attribute, any content between the opening and closing .

There are a number of advantages to using the src attribute:

Loading scripts from servers other than the one that served the document that uses the script has important security implications. The same-origin security policy described in §13.6.2 prevents JavaScript in a document from one domain from interacting with

13.2 Embedding JavaScript in HTML | 313

content from another domain. However, notice that the origin of the script itself does not matter: only the origin of the document in which the script is embedded. Therefore, the same-origin policy does not apply in this case: JavaScript code can interact with the document in which it is embedded, even when the code has a different origin than the document. When you use the src attribute to include a script in your page, you are giving the author of that script (and the webmaster of the domain from which the script is loaded) complete control over your web page.

友情链接It题库(| 版权归yishouce.com所有| 友链等可联系|粤ICP备16001685号-1