php页面跳转与定时跳转页面方法
header()函数
header()函数是PHP中进行页面跳转的一种十分简单的方法。header()函数的主要功能是将HTTP协议标头(header)输出到浏览器。
header()函数的定义如下:
void header (string string [,bool replace [,int http_response_code]])
可选参数replace指明是替换前一条类似标头还是添加一条相同类型的标头,默认为替换。
第二个可选参数http_response_code强制将HTTP相应代码设为指定值。 header函数中Location类型的标头是一种特殊的header调用,常用来实现页面跳转。注意:1.location和“:”号间不能有空格,否则不会跳转。
1.使用php里head函数进行跳转
注意:head跳转前不要有任何输出,不然可能不能跳转.
header("refresh:3;url=http://www.jiaochengji.com");//限时跳转
header('location:http://www.jiaochengji.com');//立即跳转
2. HTML meta refresh 刷新与跳转(重定向)页面
Meta标签
Meta标签是HTML中负责提供文档元信息的标签,在PHP程序中使用该标签,也可以实现页面跳转。 若定义http-equiv为refresh,则打开该页面时将根据content规定的值在一定时间内跳转到相应页面。
refresh 属性值 — 刷新与跳转(重定向)页面
refresh用于刷新与跳转(重定向)页面
refresh出现在http-equiv属性中,使用content属性表示刷新或跳转的开始时间与跳转的网址
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy3621')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy3621><meta http-equiv="refresh" content="3; url=http://www.jiaochengji.com">
3.js实现页面跳转
js实现跳转主要用到location对象
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy6459')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy6459><script type='text/javascript'>
// 立即跳转
window.location.href = 'http://www.jiaochengji.com';
// 限时跳转
setTimeout(function(){
// 3秒后跳转
window.location.href = 'http://www.jiaochengji.com';
},3000);
</script>
您可能感兴趣的文章:
php页面跳转与定时跳转页面方法
php url重定向(页面跳转)的代码
js 3秒后跳转页面实例代码
php页面跳转函数 页面重定向
php如何实现页面跳转
PHP实现301跳转,及延时跳转代码
PHP 登录完成跳转上一访问页面
js 控制页面跳转的五种方法
php如何重定向页面跳转?
PHP定时跳转