日夜不得闲

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Document</title>
 6 </head>
 7 <body>
 8     <script type="text/javascript">
 9         var str = "<h2>输出浏览器的相关信息</h2>";
10             str += "浏览器的名称:"+navigator.appName;
11             str += "<br/>浏览器的版本:"+navigator.appVersion;
12             str += "<br/>操作系统的平台:"+navigator.platform;
13             str += "<br/>系统语言:"+navigator.systemLanguage;
14             str += "<br/>用户语言:"+navigator.userLanguage;
15             document.write(str);
16             document.write("<hr/>");
17             if (navigator.appVersion.index("MSIE") == -1) {
18                 document.write("我不是IE阵营");
19             } else {
20                 document.write("我是IE阵营");
21             }
22     </script>
23     <script type="text/javascript">
24         var str = "<h2>输出屏幕的有关信息</h2>";
25             str += "屏幕的宽度:"+screen.width;
26             str += "<br>屏幕的高度:"+screen.height;
27             str += "<br/>屏幕的有效宽度:"+screen.availWidth;
28             str += "<br/>屏幕的有效高度:"+screen.availHeight;
29             str += "<br/>屏幕的色深:"+screen.colorDepth;
30 
31             document.write(str);
32     </script>
33     <!--<script type="text/javascript">
34         //每隔3秒后就弹出一个hello
35         window.setInterval("alert('hello')", 3000);
36     </script>-->
37 </body>
38 </html>

文字滚动

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Document</title>
 6 </head>
 7 <body>
 8     <input type="text" value="PHP23期基础班" size="40" id="input" />
 9     <script type="text/javascript">
10         setInterval("scrolling()",50);
11 
12         var str     = "PHP23期基础班";
13         var str_len = str.length;
14         var flag    = "right";
15 
16         function scrolling()
17         {
18             var input_obj = document.getElementById("input");
19             if (flag == "right") 
20             {            
21                 str = " "+str;
22                 input_obj.value = str;
23 
24                 if (str.length == 64) 
25                 {
26                     flag = "left";
27                 }
28             }
29                 else 
30                 {
31                      str = str.substr(1);
32                      input_obj.value=str;
33                      if(str.length == str_len)
34                      {
35                          flag = "right";
36                      }
37                 }
38         }
39 
40     </script>
41 
42 </body>
43 </html>

动态时钟

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Document</title>
 6     <style class="text/css">
 7     </style>
 8 </head>
 9 <body>
10     <div id="div1"></div>
11     <script type="text/javascript">
12         var yue = ["01","02","03","04","05","06","07","08","09",10,11,12];
13         function getTimes(){
14             
15             var myDate = new Date();
16             var year   = myDate.getFullYear();
17             var month  = yue[myDate.getMonth()];
18             var today  = i(myDate.getDate());
19             var hours  = i(myDate.getHours());
20             var min    = i(myDate.getMinutes());
21             var seconds= i(myDate.getSeconds());
22 
23             var str = year+"-"+month+"-"+today+"&nbsp;"+hours+":"+min+":"+seconds;
24             var div_obj = document.getElementById("div1");
25             div_obj.innerHTML = str;
26 
27             setTimeout("getTimes()",1000);
28         }
29         getTimes();
30 
31         function i (m) {
32              return m<10 ? "0"+m : m;  
33         }
34     </script>
35 </body>
36 </html>

 

posted on 2016-12-11 21:57  日夜不得闲  阅读(155)  评论(0编辑  收藏  举报