JavaScript基础

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5 <title>javascript基础</title>
 6 <script type="text/javascript">
 7        function show()
 8        {
 9            alert("js学习之旅!");
10        }
11 </script>
12 
13 <script src="jsfile.js" type="text/javascript">
14 </script>
15 
16 <script type="text/javascript">
17       var p = 3.14;
18       function compute(r)
19       {
20           return 2*p*r*r;
21       }
22       function show3()
23       {
24         var r = document.getElementById("radius").value;
25         var area = compute(r);
26         document.getElementById("area").value=area;  
27       }
28 </script>
29 
30 <script type="text/javascript>  //这个有点问题 显示不出来
31        function show4()
32       {
33           confirm("确认提交吗?")
34       prompt("提示。。。。")
35       }
36 </script>
37 
38 </head>
39 
40 <body onload="show2()">
41       <script type="text/javascript">
42        document.write("js学习");
43       </script>
44       
45       <form>
46       输入半径:<input type="text"; name="r" id="radius">
47       <input type="button" value="计算" onclick="show3()">
48       圆的面积:<input type="text" name="area" id="area">
49       </form>
50       <input type="text"; name="确认框&nbsp提示框" onclick="show4()">
51 </body>
52 </html>

 

1 //外部js文件代码
2 function show2()
3        {
4            alert("js2222学习之旅!");
5        }

 

posted @ 2014-11-15 03:11  水门  阅读(175)  评论(0编辑  收藏  举报