这篇文章主要介绍了js 3秒后跳转页面的实现代码,需要的朋友可以参考下
隔多少秒后自动跳转到其它页(js脚本) 方法一: 在<head></head>之间加入js 代码如下: <script language="javascript"> var secs = 3; //倒计时的秒数 var URL ; function Load(url){ URL = url; for(var i=secs;i>=0;i--) { window.setTimeout('doUpdate(' + i + ')', (secs-i) * 1000); } } function doUpdate(num) { document.getElementById('ShowDiv').innerHTML = '将在'+num+'秒后自动跳转到主页' ; if(num == 0) { window.location = URL; } } </script> 然后在<body>里面加上<body onload="Load('index.asp')"> index.asp为自己要跳转的页面。 在<body></body>之间加上<div id="ShowDiv"></div> 方法二: 代码如下: <p style="text-indent: 2em; margin-top: 30px;"> 系统将在 <span id="time">5</span> 秒钟后自动跳转至新网址,如果未能跳转,<a href="http://www.jb51.net" title="点击访问">请点击</a>。</p> <script type="text/javascript"> delayURL(); function delayURL() { var delay = document.getElementById("time").innerHTML; var t = setTimeout("delayURL()", 1000); if (delay > 0) { delay--; document.getElementById("time").innerHTML = delay; } else { clearTimeout(t); window.location.href = "http://www.jb51.net"; } } </script>