Think before you speak, read before you think.

javascript跳转

by

in

在header里写功能函数

var secs =5;
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('timer').innerHTML= num;
if(num == 0){ window.location = URL;}
}

写一个span,然后不断更新秒数

span id="timer"
javascript:
Load("/login");

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *