1.输出工具
A. alert();
B. document.write()
C. prompt("","")
2.javascript如何在html页面当中进行放置
A.<script></script>
***************************************
javascript可以在html页面当中的任何位置来进行调用,
但是他们还是一个整体,是相互联系,相互影响。
***************************************
B.可以在超链接或是重定向的位置调用javascript代码
格式:"javascript:alert('我是超链接')"
重定向格式:action="javascript:alert('我是表单')"
3.在事件后面进行调用
A.格式:οnclick="alert('我是事件')"
B.<script for="two" event="onclick">
alert("我是DIV2");
</script>
4.调用外部javascript文件
格式: <script src="2.js"></script>
***************************************
在调用页面<script>标签对当中不能有任何代码
在js脚本中不能出现<script>标签对
但是他们还是一个整体,是相互联系,相互影响。
***************************************
5.javascript注释:
1.对付旧的浏览器
<!-- -->
2.真正注释符号。
A.行内注释 //
B.块注释/*
*/
<!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=gb2312" /> <title>place3</title> <style> .one{ width:100px; height:100px; background:red; font-size:12px; color:blue; } .two{ width:200px; height:300px; background:blue; font-size:12px; color:red; } </style> <script for="two" event="onclick"> alert("我是DIV2"); </script> </head> <body> <div class="one" οnclick="alert('我是事件')"> 欢迎收看后盾网视频教程,收看更多原创视频请到后盾网论坛下载! </div> <div class="two" id="two"> 欢迎收看后盾网视频教程,收看更多原创视频请到后盾网论坛下载! </div> </body> </html> |