在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");
Leave a Reply