代码改变世界

写了个比较SB的东西

2010-05-31 17:12  jimhou  阅读(108)  评论(0)    收藏  举报

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
4  <head>
5  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6  <title>无标题 1</title>
7  <style type="text/css">
8 body{
9 background-color:silver;
10  }
11 #clock{
12 position:absolute;
13 top:50%;left:50%;
14  }
15 #txt{
16 position:relative;
17 top:-50px;left:-50px;
18 height:100px;
19 width:100px;
20 font-size:90px;
21 text-align:right;
22 color:#33CC33;
23 background-color:#000;
24  }
25 #button{
26 position:relative;
27 left:-75px;top:-30px;
28  }
29 }
30  </style>
31  <script type="text/javascript">
32  <!--
33  var t;
34  var c = 0;
35  function timecount(){
36 c = document.getElementById("txt").value = c;
37 c = c + 1;
38 t = setTimeout("timecount()",1000);
39 }
40
41  function stopcount(){
42 clearTimeout(t);
43 }
44  //-->
45  </script>
46  </head>
47
48  <body>
49  <h1 align="center">Stop watch</h1>
50  <div id="clock">
51 <form>
52 <input type="text" id="txt" />
53 <div id="button">
54 <input type="button" value="start" onclick="timecount()"/>
55 <input type="button" value="stop" onclick="stopcount()"/>
56 <input type="reset" onclick ="location.reload()" value="reset"/>
57 </div>
58 </form>
59  </div>
60  </body>
61  </html>
62

我想知道除了刷新页面之外,还有没有别的办法去初始化全局变量