- 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";
- }
- }
来源: http://www.codesnippet.cn/detail/2506201512929.html