js控制页面定时跳转
[JavaScript]代码
<body onload="redirector();"></body> <table> <tr> <td><span id="redirector"></span> </tr> </table>
var n=3; //设定时间3s function redirector(){ if(n+1>0){ //标题提示 document.title="本页将在" + n + "秒后跳转到登录界面!"; //页面提示 document.getElementById('redirector').innerHTML="本页将在 <span style=\"color:red;\"> " + n + "</span> 秒后跳转到登录界面!"; n--; setTimeout("redirector()",1000); //1s后执行redirector() } else { window.location.href="defaultHome.action"; } }