1 <!DOCTYPE html> 2 <html> 3 <head lang="en"> 4 <meta charset="UTF-8"> 5 <title></title> 6 <script type="text/javascript"> 7 var t = 5;//设定跳转的时间 8 var intervalId = setInterval("refer()", 1000); //启动1秒定时 9 function refer() { 10 if (t-- == 0) 11 location.href = "./h.html"; //设定跳转的链接地址 12 document.getElementById('show').innerHTML = "" + t + "秒后自动跳转到指定页面"; //显示倒计时 13 } 14 15 function ref() { 16 clearInterval(intervalId); //解除倒计时. 17 location.href = "./h.html"; //设定跳转的链接地址 18 } 19 </script> 20 </head> 21 <body> 22 <span id="show"></span> 23 <input type="button" value="手动跳转" onclick="ref()"> 24 </body> 25 </html>