============================================================================== 倒计时的自动跳转.html <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title></title> </head> <body onload="start_timer()"> <script> var i=3; var timer=null; function change() { var lab = document.getElementById("lab"); lab.innerText = i+"秒后自动跳转到2.html..."; i--; if(i==0) { window.clearInterval(timer); timer=null; //window.location.href = "2.html"; var a = document.getElementById("a1"); doclick(a); } } function start_timer() { timer = window.setInterval("change()",1000); } function doclick(obj) { javascript:location.replace(obj.href); event.returnValue=false; } </script> <label id="lab">3秒后自动跳转到2.html...</label> <a id="a1" href="2.html" onclick="doclick(this)">直接跳转到2.html</a> </body> </html>