js固定时间后新窗口跳转

方法一:

请等待10
[code lang=”js”]
<script type="text/javascript">
function run(){
var s = document.getElementById("dd");
if(s.innerHTML == 0){
window.open(‘http://shanmao.me’);
return false;
}
s.innerHTML = s.innerHTML * 1 – 1;
}
window.setInterval("run();", 1000);
</script>
[/code]

方法二:
[code lang=”js”]
<script type="text/javascript">
<!–
var duration=900;
var endTime = new Date().getTime() + duration + 100;
function interval()
{
var n=(endTime-new Date().getTime())/1000;
if(n<0) return;
document.getElementById("timeout").innerHTML = n.toFixed(3);
setTimeout(interval, 10);
}
window.onload=function()
{
setTimeout("window.open(‘http://shanmao.me’)", duration);
interval();
}
//–>
</script>
[/code]


等待10秒

现在剩下 10.000 秒后 将自动跳转


方法二比较靠谱,大家自己试了就知道。方法二是js内部自动执行。

“js固定时间后新窗口跳转”的一个回复

评论已关闭。