JavaScript在网页中的位置
2015-06-28 11:04
561 查看
JavaScript is inserted into HTML pages by using the <script> element. This element can be used
to embed JavaScript into an HTML page, leaving it inline with the rest of the markup, or to include
JavaScript that exists in an external fi le. The following are key points:
➤ To include external JavaScript files, the src attribute must be set to the URL of the fi le to
include, which may be a file on the same server as the containing page or one that exists on
a completely different domain.
➤ All <script> elements are interpreted in the order in which they occur on the page. The
code contained within a <script> element must be completely interpreted before code in
the next <script> element can begin so long as defer and async attributes are not used.
➤ For nondeferred scripts, the browser must complete interpretation of the code inside
a <script> element before it can continue rendering the rest of the page. For this reason,
<script> elements are usually included toward the end of the page, after the main content
and just before the closing </body> tag.
➤ You can defer a script’s execution until after the document has rendered by using the defer
attribute. Deferred scripts always execute in the order in which they are specified.
➤ You can indicate that a script need not wait for other scripts and also not block the
document rendering by using the async attribute. Asynchronous scripts are not guaranteed
to execute in the order in which they occur in the page.
By using the <noscript> element, you can specify that content is to be shown only if scripting
support isn’t available on the browser. Any content contained in the <noscript> element will not be
rendered if scripting is enabled on the browser.
From:Professional JavaScript for Web Developers (2012)
to embed JavaScript into an HTML page, leaving it inline with the rest of the markup, or to include
JavaScript that exists in an external fi le. The following are key points:
➤ To include external JavaScript files, the src attribute must be set to the URL of the fi le to
include, which may be a file on the same server as the containing page or one that exists on
a completely different domain.
➤ All <script> elements are interpreted in the order in which they occur on the page. The
code contained within a <script> element must be completely interpreted before code in
the next <script> element can begin so long as defer and async attributes are not used.
➤ For nondeferred scripts, the browser must complete interpretation of the code inside
a <script> element before it can continue rendering the rest of the page. For this reason,
<script> elements are usually included toward the end of the page, after the main content
and just before the closing </body> tag.
➤ You can defer a script’s execution until after the document has rendered by using the defer
attribute. Deferred scripts always execute in the order in which they are specified.
➤ You can indicate that a script need not wait for other scripts and also not block the
document rendering by using the async attribute. Asynchronous scripts are not guaranteed
to execute in the order in which they occur in the page.
By using the <noscript> element, you can specify that content is to be shown only if scripting
support isn’t available on the browser. Any content contained in the <noscript> element will not be
rendered if scripting is enabled on the browser.
From:Professional JavaScript for Web Developers (2012)
相关文章推荐
- 学习Javascript闭包(Closure)
- 理解 Javascript 的闭包
- 那些逐步掌握的JavaScript('arguments')
- Jsp:param标签的使用
- Extjs布局
- javascript中遇到的字符串对象处理
- js类型判断的方法
- Js学习文件上传
- 最简单的处理MVC中默认的Json方法返回时间的问题
- 100多个基础常用JS函数和语法集合大全
- 【HM】第3课:JavaScript高级
- JS的碰撞周期移动
- JSON处理
- 在JSP前台和后台传递参数乱码汇总
- 11. Firefox如何调试js脚本:
- Array的队列方法&重排序方法—— JS学习笔记2015-6-27(第68天)
- js 函数的参数 问题 arguments对象 及闭包
- JavaScript语法 (顺序+判断+选择+循环+其他=五种语句)演示
- Web 开发的 JavaScript 框架资料收集(15款)
- 谈谈Ext JS的组件——布局的使用方法续二