码迷,mamicode.com
首页 > Web开发 > 详细

js定时跳转页面

时间:2015-07-03 19:18:29      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:js   jquery   

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; />
<script type="text/javascript" src=jquery.min.js"></script>
<title></title>


</head>
<body onload="redirector();"></body>
 
<table>
       <tr>
             <td><span id="redirector"></span>
       </tr>
</table>
<script>
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";
      }
}
</script>
</html>
<span style="font-size:14px;">欢迎加入Java交流群,不管是前端后端都是一个很好的学习平台哦,群号:398918539</span>

版权声明:本文为博主原创文章,未经博主允许不得转载。

js定时跳转页面

标签:js   jquery   

原文地址:http://blog.csdn.net/u010407050/article/details/46744071

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!