js 3秒后跳轉(zhuǎn)頁面的實(shí)現(xiàn)代碼
隔多少秒后自動(dòng)跳轉(zhuǎn)到其它頁(js腳本)
方法一:
在<head></head>之間加入js
<script language="javascript">
var secs = 3; //倒計(jì)時(shí)的秒數(shù)
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+'秒后自動(dòng)跳轉(zhuǎn)到主頁' ;
if(num == 0) { window.location = URL; }
}
</script>
然后在<body>里面加上<body onload="Load('index.asp')"> index.asp為自己要跳轉(zhuǎn)的頁面。
在<body></body>之間加上<div id="ShowDiv"></div>
方法二:
<p style="text-indent: 2em; margin-top: 30px;">
系統(tǒng)將在 <span id="time">5</span> 秒鐘后自動(dòng)跳轉(zhuǎn)至新網(wǎng)址,如果未能跳轉(zhuǎn),<a href="http://chabaoo.cn" title="點(diǎn)擊訪問">請(qǐng)點(diǎn)擊</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://chabaoo.cn";
}
}
</script>
相關(guān)文章
js定時(shí)顯示廣告的實(shí)現(xiàn)代碼[已測(cè)]
有時(shí)候需要定時(shí)顯示指定的廣告,那么就可以參考下面的代碼了2012-02-02用js實(shí)現(xiàn)頁面顯示當(dāng)前日期和時(shí)間的代碼
js時(shí)間日期顯示效果代碼2008-04-04團(tuán)購、定時(shí)搶購倒計(jì)時(shí)js版
團(tuán)購、定時(shí)搶購倒計(jì)時(shí)實(shí)現(xiàn)代碼,需要的朋友可以參考下。2010-08-08datePicker——日期選擇控件(with jquery)
用法很簡(jiǎn)單,而且js文件也很小,之前也見過一些日期選擇控件,但個(gè)頭都比較大,影響速度2007-02-02javascript倒計(jì)時(shí)功能實(shí)現(xiàn)代碼
javascript倒計(jì)時(shí)功能實(shí)現(xiàn)代碼,需要的朋友可以參考下2012-06-06