js實現指定時間跳轉到另一個頁面


 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <title>setTimeout</title>
 5 </head>
 6 <body>
 7 <h1>跳轉頁面</h1>
 8 <form>
 9     <div>
10         <p><span id="skip"></span>秒后跳轉到主頁面</p>
11     </div>
12 </form>
13 <script type="text/javascript">
14     var t = 5;
15     function showTime() {
16         t -= 1;
17         document.getElementById('skip').innerHTML = t;
18         if (t == 0) {
19             window.location.href = 'http://www.baidu.com';
20         }
21         setTimeout("showTime()",1000);
22     }
23     showTime();
24 </script>
25 </body>
26 </html>
js實現簡單跳轉

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM