Maison > php教程 > php手册 > le corps du texte

php页面跳转与定时跳转页面方法

WBOY
Libérer: 2016-05-25 16:44:26
original
816 Les gens l'ont consulté

在php中页面跳转我们用到的是header函数了,如果要定时跳转页面我们就必须使用js或html了,下面我来给各位同学总结一下各种页面跳转的实现程序.

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.phprm.com");//限时跳转 

header('location:http://www.phprm.com');//立即跳转 

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

Meta标签:Meta标签是HTML中负责提供文档元信息的标签,在PHP程序中使用该标签,也可以实现页面跳转,若定义http-equiv为refresh,则打开该页面时将根据content规定的值在一定时间内跳转到相应页面.

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

refresh用于刷新与跳转(重定向)页面

refresh出现在http-equiv属性中,使用content属性表示刷新或跳转的开始时间与跳转的网址,代码如下:

3.js实现页面跳转

js实现跳转主要用到location对象,代码如下:

<script type=&#39;text/javascript&#39;> 
 // 立即跳转 
 window.location.href = &#39;http://www.phprm.com&#39;; 
 // 限时跳转 
 setTimeout(function(){ 
  // 3秒后跳转 
  window.location.href = &#39;http://www.phprm.com&#39;; 
 },3000); 
</script>
Copier après la connexion


文章网址:

随意转载^^但请附上教程地址。

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Recommandations populaires
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!