根据时间改变背景

 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>时间</title>
 6 </head>
 7 
 8 <body>
 9 <script type="text/javascript">
10     function changeBg(){
11      var date = new Date(),
12       time = date.getHours();
13   //
14   if(time > 6 && time < 18){//白天
15       document.body.style.background = "#080" ;
16   }else{
17       document.body.style.background = "#f00" ; 
18   }
19    
20  }
21  changeBg();
22 </script>
23 </body>
24 </html>

 

posted @ 2013-08-27 16:18  鲤鱼在睡觉  阅读(151)  评论(0编辑  收藏  举报