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 <title>10秒后跳转</title> 5 <script type="text/javascript"> 6 onload = function () { 7 //秒数每秒减1 8 var countDown = setInterval(function () { 9 var second = document.getElementById("second"); 10 second.innerHTML -= 1; 11 //秒数为0时跳转到百度 12 if (second.innerHTML == 0) { 13 clearInterval(countDown); 14 location.href = "http://www.baidu.com"; 15 } 16 }, 1000); 17 } 18 </script> 19 </head> 20 <body> 21 <p> 22 页面将在<span id="second">3</span>秒后跳转 23 </p> 24 </body> 25 </html>
时间: 2024-11-06 08:51:32