定时页面定时跳转jquery实现和js实现
2016-06-26 20:08
471 查看
jquery实现定时页面跳转
<script language="javascript" type="text/javascript">
$(document).ready(function(){
var second=parseInt($("#totalSecond").val());
setInterval(redirect, 3000);
function redirect() {
if (second < 0) {
alert("fff")
<!--定义倒计时后跳转页面-->
location.href = 'index.jsp';
} else {
$("#totalSecond").val(second-1);
second=parseInt($("#totalSecond").val());
alert(typeof (second));
}
}
});
</script>
js实现页面的定时肉跳转
<!DOCTYPE html >
<html>
<head>
<title></title>
<style type="text/css">
#ShowDiv{ font-size:18px;}
</style>
<script language='javascript' type='text/javascript'>
<!--
var secs =6; //倒计时的秒数
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('ShowDiv').innerHTML = '您尚未登录或登录信息已经过期,系统将在 <strong>'+num+'</strong> 秒后自动跳转到登录页面' ;
if(num == 0) { window.location=URL; }
}
// -->
</script>
</head>
<body>
<div id="ShowDiv"></div>
<script language="javascript">
<!--
Load("/index.html"); //要跳转到的页面
// -->
</script>
</body>
</html>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
var second=parseInt($("#totalSecond").val());
setInterval(redirect, 3000);
function redirect() {
if (second < 0) {
alert("fff")
<!--定义倒计时后跳转页面-->
location.href = 'index.jsp';
} else {
$("#totalSecond").val(second-1);
second=parseInt($("#totalSecond").val());
alert(typeof (second));
}
}
});
</script>
js实现页面的定时肉跳转
<!DOCTYPE html >
<html>
<head>
<title></title>
<style type="text/css">
#ShowDiv{ font-size:18px;}
</style>
<script language='javascript' type='text/javascript'>
<!--
var secs =6; //倒计时的秒数
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('ShowDiv').innerHTML = '您尚未登录或登录信息已经过期,系统将在 <strong>'+num+'</strong> 秒后自动跳转到登录页面' ;
if(num == 0) { window.location=URL; }
}
// -->
</script>
</head>
<body>
<div id="ShowDiv"></div>
<script language="javascript">
<!--
Load("/index.html"); //要跳转到的页面
// -->
</script>
</body>
</html>
相关文章推荐
- jquery中css()函数的用法
- jquery
- 简单的jquery模仿复选框全选全不选功能
- jquery基础知识
- jQuery 选择器
- jQuery基础
- jQuery 语法
- jQuery全屏滚动插件FullPage.js
- jQuery Easing 使用方法及其图解
- jquery
- javascript ajax和jquery ajax
- jquery插件-validation plugin
- jQuery根据滚动方向做导航条动画
- jquery元素设置
- jquery 基础
- jQuery $.fn.extend方式自定义插件
- jquery课堂笔记
- Jquery联表
- jquery概述
- javajquery