当前位置: 首页 > 网络学院 > 网页制作基础教程 > HTML > HTML Scripts

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

HTML Scripts


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

Add scripts to HTML pages to make them more dynamic and interactive.
加上脚本来让HTML更具动态性和交互性


Examples
例子

Insert a script
插入一脚本
This example demonstrates how to insert a script into your HTML document.
演示怎样在你的页面里插入脚本

Work with browsers that do not support scripts
不支持脚本的浏览器
This example demonstrates how to handle browsers that do not support scripting.
演示怎样针对那些不支持脚本的浏览器做些处理


Insert a Script into HTML Page
在HTML页中插入脚本

A script in HTML is defined with the <script> tag. Note that you will have to use the type attribute to specify the scripting language.
在HTML中脚本是用<script>标签定义的.注意得用type属性来指明所用的脚本语言.

<html>
<head>

</head>
<body>
<script type="text/javascript">
document.write("Hello World!")
</script>
</body>
</html>

The script above will produce this output:
上面的脚本会生成:

Hello World!

Note: To learn more about scripting in HTML, visit our JavaScript School.
注意:学习更多的HTML脚本,请访问JavaScript School.


How to Handle Older Browsers
怎样处理老的浏览器

A browser that does not recognize the <script> tag at all, will display the <script> tag's content as text on the page. To prevent the browser from doing this, you should hide the script in comment tags. An old browser (that does not recognize the <script> tag) will ignore the comment and it will not write the tag's content on the page, while a new browser will understand that the script should be executed, even if it is surrounded by comment tags.
一些浏览器不支持<srcipt>标签,会将里面的内容以文本的形式显示出来,为了防止这样,你应该将脚本内容用注释的方法来进行隐藏.

Example
例子

JavaScript:
<script type="text/javascript">
<!--
document.write("Hello World!")
//-->
</script>

VBScript:
<script type="text/vbscript">
<!--
document.write("Hello World!")
'-->
</script>

 


The <noscript> Tag
<noscript>标签

In addition to hiding the script inside a comment, you can also add a <noscript> tag.
除在注释里隐藏脚本,你还可以添加一个<noscript>标签.

The <noscript> tag is used to define an alternate text if a script is NOT executed. This tag is used for browsers that recognize the <script> tag, but do not support the script inside, so these browsers will display the text inside the <noscript> tag instead. However, if a browser supports the script inside the <script> tag it will ignore the <noscript> tag.
<noscript>标签用来给不能执行的脚本来定义说明文字.这个标签是为那些不能支持<script>标签的浏览器而准备的,不执行脚本而是显示<noscript> 里的文字.

Example
例子

JavaScript:
<script type="text/javascript">
<!--
document.write("Hello World!")
//-->
</script>
<noscript>Your browser does not support JavaScript!</noscript>

VBScript:
<script type="text/vbscript">
<!--
document.write("Hello World!")
'-->
</script>
<noscript>Your browser does not support VBScript!</noscript>

 


Script Tags
脚本标签

Tag
标签
Description
描述
<script> Defines a script
定义一个脚本
<noscript> Defines an alternate text if the script is not executed
定义说明
<object> Defines an embedded object
定义布置对象
<param> Defines run-time settings (parameters) for an object
设置对象
<applet> Deprecated. Use <object> instead
不推荐。

评论 (0) All

登陆 | 还没注册?