javascript倒计时 页面跳转

  
  
  
  
Javascript5秒之后跳转到指定页面


 
   
   
   
   
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
  2. <html> 
  3.     <head> 
  4.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
  5.         <title>Count</title> 
  6.     </head> 
  7.     <body> 
  8.  
  9. <div style="text-align: center " >Enter baidu in
  10. <span id="totalSecond" style="text-align: center ;font-family: GulimChe;font-size: 100px;">5
  11. </span>seconds </div> 
  12.  
  13. <script language="javascript" type="text/javascript"> 
  14.     var second = document.getElementById('totalSecond').textContent; 
  15.  
  16.     if (navigator.appName.indexOf("Explorer") > -1) 
  17.     { 
  18.         second = document.getElementById('totalSecond').innerText; 
  19.     } else 
  20.     { 
  21.         second = document.getElementById('totalSecond').textContent; 
  22.     } 
  23.  
  24.  
  25.     setInterval("redirect()", 1000); 
  26.     function redirect() 
  27.     { 
  28.         if (second < 0
  29.         { 
  30.             location.href = 'www.baidu.com'; //go to baidu
  31.         } else 
  32.         { 
  33.             if (navigator.appName.indexOf("Explorer") > -1) 
  34.             { 
  35.                 document.getElementById('totalSecond').innerText = second--; 
  36.             } else 
  37.             { 
  38.                 document.getElementById('totalSecond').textContent = second--; 
  39.             } 
  40.         } 
  41.     } 
  42. </script> 
  43.     </body> 
  44. </html> 

 

你可能感兴趣的:(JavaScript,职场,休闲)