页面定时跳转
2015-03-19 16:06
148 查看
实现页面定时跳转(也称倒计时跳转)做一下总结,各种定时跳转代码记录如下:
(1)使用setTimeout函数实现定时跳转(如下代码要写在body区域内)
<script type=”text/javascript”>
//3秒钟之后跳转到指定的页面
setTimeout(window.location.href=’http://www.zan3.com/zantag/%E5%BB%B6%E8%BF%9F%E5%8A%A0%E8%BD%BD’,3);
</script>
(2)html代码实现,在页面的head区域块内加上如下代码
<!–5秒钟后跳转到指定的页面–>
<meta http-equiv=”refresh” content=”5;url=http://www.zan3.com/zan2386.html” />
(3)稍微复杂点,多见于登陆之后的定时跳转
<html xmlns=”http://www.zan3.com/zan2366.html”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>js定时跳转页面的方法</title>
</head>
<body>
<script type=”text/javascript”>
var t=10;//设定跳转的时间
setInterval(“refer()”,1000); //启动1秒定时
function refer(){
if(t==0){
location=”http://www.zan3.com/zan2391.html”; //设定跳转的链接地址
}
document.getElementById(‘zanshow’).innerHTML=””+t+”秒后跳转到php程序员教程网”; //显示倒计时
t–; //计数器递减
}
</script>
<span id=”zanshow”></span>
</body>
</html>
(4)利用 php header实现页面重定向已达到页面定时跳转的目的
<?php
/**
@title:PHP实现定时跳转
@功能:等待指定的时间,然后再跳转到指定页面(代替html meta方式)
*/
header(“refresh:3;url=http://www.zan3.com/zan1180.html”);
echo ‘正在加载,请稍等…<br>三秒后自动跳转';
/*
说明:若等待时间为0,则与header(“location:”)等效。
*/
?>
(1)使用setTimeout函数实现定时跳转(如下代码要写在body区域内)
<script type=”text/javascript”>
//3秒钟之后跳转到指定的页面
setTimeout(window.location.href=’http://www.zan3.com/zantag/%E5%BB%B6%E8%BF%9F%E5%8A%A0%E8%BD%BD’,3);
</script>
(2)html代码实现,在页面的head区域块内加上如下代码
<!–5秒钟后跳转到指定的页面–>
<meta http-equiv=”refresh” content=”5;url=http://www.zan3.com/zan2386.html” />
(3)稍微复杂点,多见于登陆之后的定时跳转
<html xmlns=”http://www.zan3.com/zan2366.html”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>js定时跳转页面的方法</title>
</head>
<body>
<script type=”text/javascript”>
var t=10;//设定跳转的时间
setInterval(“refer()”,1000); //启动1秒定时
function refer(){
if(t==0){
location=”http://www.zan3.com/zan2391.html”; //设定跳转的链接地址
}
document.getElementById(‘zanshow’).innerHTML=””+t+”秒后跳转到php程序员教程网”; //显示倒计时
t–; //计数器递减
}
</script>
<span id=”zanshow”></span>
</body>
</html>
(4)利用 php header实现页面重定向已达到页面定时跳转的目的
<?php
/**
@title:PHP实现定时跳转
@功能:等待指定的时间,然后再跳转到指定页面(代替html meta方式)
*/
header(“refresh:3;url=http://www.zan3.com/zan1180.html”);
echo ‘正在加载,请稍等…<br>三秒后自动跳转';
/*
说明:若等待时间为0,则与header(“location:”)等效。
*/
?>
相关文章推荐
- Asp.net实现网站提示信息页面后的定时自动跳转到指定页面
- HTML 定时页面跳转
- Android中应用界面主题Theme使用方法和页面定时跳转应用
- javascript使用定时函数实现跳转到某个页面
- Android启动页面定时跳转的三种方法
- JS定时刷新页面及跳转页面
- 页面跳转和定时刷新
- 基于jQuery的页面定时跳转
- ASP.NET中配合JS实现页面计时(定时)自动跳转
- 页面定时跳转(倒计时跳转)代码总结
- js实现页面跳转,纯html实现网页定时跳转
- HTML页面定时跳转方法
- 让浏览器定时刷新网页或跳转至其他页面
- 基于JavaScript实现定时跳转到指定页面
- JS定时刷新页面及跳转页面
- JavaScript实现定时页面跳转
- 页面定时跳转
- HTML 定时页面跳转
- js实现页面定时跳转
- js页面用定时任务通过AJAX获取后台数据,但是从这个页面跳转到其他页面后,定时任务仍然在定时请求后台