当前位置: 首页 > 网络学院 > 网页制作基础教程 > HTML > HTML <script>标签

HTML
HTML Head
HTML Meta
HTML URLs
HTML Scripts
HTML 属性
HTML 事件
HTML URL-encode
HTML Web服务器
HTML 摘要
HTML 实例
标签列表
标准属性
事件属性
ASCII码
特殊字符
HTTP状态消息

HTML <script>标签


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 349 ::
收藏到网摘: n/a

定义与用法

Defines a script, such as a JavaScript.
定义一脚本,比如像JavaScript


在HTML和XHTML中的区别

The "language" attribute of the script element was deprecated in HTML 4.01.
HTML4.01不推荐script元素的"language"属性

The "language" attribute of the script element is not supported in XHTML 1.0 Strict DTD.
XHTML1.0严密型DTD不支持script元素的"language"属性


提示与注意点

Note: Code within this element is executed immediately when the page is loaded, if it is not in a function. Script that appears after a <frameset> tag will be ignored.
注意:当页面被加载的时候这个元素里的非函数代码会立即执行。出现在<frameset>标签后的脚本会被忽视。


实例

代码 输出
<script type="text/javascript">
document.write("Hello World!")
</script>
 


必要属性

DTD indicates in which DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.
下表中的DTD列指明了被支持的DTD属性。S=Strict(精确的),T=Transitional(传统的),F=Frameset(框架)

属性 描述 DTD
type text/ecmascript
text/javascript
text/jscript
text/vbscript
text/vbs
text/xml
Indicates the MIME type of the script
指出脚本的MIME类型
STF

可选属性

属性
描述 DTD
charset charset Defines the character encoding used in script
定义在脚本中使用的字符编码
STF
defer defer Indicates that the script is not going to generate any document content. The browser can continue parsing and drawing the page
表明该脚本不再继续生成任何文档内容。浏览器将继续解析并绘制页面
STF
language javascript
livescript
vbscript
other
Specifies the scripting language. Deprecated. Use the type attribute instead.
指定脚本语言。不推荐使用。推荐用type属性
TF
src URL Defines a URL to a file that contains the script (instead of inserting the script into your HTML document, you can refer to a file that contains the script)
定义一个目标URL或是一个文件,其包含脚本的内容。
STF

标准属性

xml:space

For a full description, go to Standard Attributes.
查看完整的属性

事件属性

NONE


尝试与演示

Insert a script
How to insert a script into your HTML document.
如何在HTML中加入脚本

Work with browsers that do not support scripts
How to handle browsers that do not support scripting.
为无法支持脚本的浏览器做些处理

评论 (0) All

登陆 | 还没注册?