JavaScript概述
时间:2010-09-29 来源:露初晞
在HTML中嵌入JavaScript的方法
1.利用<script>标签的language属性
<script language="javascript">
</script>
2.利用<script>标签的src属性
<script language="JavaScript" src="aaa.js">
</script>
aaa.js为:
<!--Begin hiding JavaScript
//alert("Hello");
document.write("This text was generated by code in the aaa.js file.")
//End hiding JavaScript-->
3.利用onLoad方式
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script language="javascript"> <!-- function done(){ alert("This page has finished loading."); } //--> </script> </head> <body onLoad="done()"> </body> </html>
在不兼容的浏览器中隐藏JavaScript代码
<!-- 开始隐藏JavaScript
JavaScript声明
//结束 JavaScript隐藏-->
相关阅读 更多 +