php实现页面重定向及限时跳转的几种方法

日期 2013年01月11日 15:36

分类 PHP

标签

浏览 5819

字数统计: 703(字)

本文发布于 11 年前, 内容可能已经过时或失效!

文章目录

php实现页面跳转及限时跳转的几种方法:

1.使用php里head函数进行跳转

header("refresh:3;url=http://yanue.net");//限时跳转
header('location:http://yanue.net');//立即跳转

注意:head跳转前不要有任何输出,不然可能不能跳转.

2. HTML meta refresh 刷新与跳转(重定向)页面

refresh 属性值  – 刷新与跳转(重定向)页面

  • refresh用于刷新与跳转(重定向)页面
  • refresh出现在http-equiv属性中,使用content属性表示刷新或跳转的开始时间与跳转的网址
<meta http-equiv="refresh" content="3; url=http://yanue.net">

3.js实现页面跳转

<script type='text/javascript'>
        // 立即跳转
        window.location.href = 'http://yanue.net';
        // 限时跳转
        setTimeout(function(){
                // 3秒后跳转
                window.location.href = 'http://yanue.net';
        },3000);
</script>