Rumah  >  Artikel  >  pembangunan bahagian belakang  >  php如何实现弹出新页面

php如何实现弹出新页面

藏色散人
藏色散人asal
2020-08-31 09:14:226858semak imbas

php实现弹出新页面的方法:1、使用“header("Location:".PSYS_BASE_URL."user/index");”方法实现弹出跳转;2、通过“header("refresh:3;url='createTag' ");”。

php如何实现弹出新页面

推荐:《PHP视频教程

PHP实现弹出提示框并跳转到新页面

PHP实现弹出提示框后返回上一个页面

<?php
echo "<script>alert(&#39;退出成功!&#39;);location.href=&#39;".$_SERVER["HTTP_REFERER"]."&#39;;</script>"; 
?>

alert里面是提示的消息,href是提示后跳转的页面。

如果alert中文乱码,加入下面代码

echo &#39;<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />&#39;;

我们可以考虑封装成函数来调用,下面是我自己封装的页面跳转函数

/**
* 页面跳转方法
* @param $msg 提示说明
* @param null $path 跳转路径
* @param null $parent 为ture则返回父窗口
*/
function messageInfo($msg,$path=NULL,$parent=NULL){
  if($parent === true){
      $str="<script>alert(&#39;".$msg."&#39;);parent.location.href=&#39;".$path."‘</script>";
    }else if(empty($path)){
      $str="<script>alert(&#39;".$msg."&#39;);history.back()</script>";
    }else{
      $str="<script>alert(&#39;".$msg."&#39;);location.href=&#39;".$path."&#39;</script>";
  }
  echo &#39;<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />&#39;;//支持中文
  echo $str;
}

使用方法:messageInfo(‘操作成功!’,’http://www.demourl.com/product_list.php’);

其他跳转方法

代码如下:

echo "<script> alert(&#39;no loginid&#39;); </script>"; 
echo "<meta http-equiv=&#39;Refresh&#39; content=0; URL=$url>";

$url就是要跳转的页面,同时,这个还能控制跳转时间,content后面的0就是表示0秒后跳转。

两个直接跳转的方式:

代码如下:

header("Location:".PSYS_BASE_URL."user/index");

代码如下:

// echo "<script> alert(&#39;创建tag成功!&#39;); </script>";
   // header("refresh:3;url=&#39;createTag&#39; ");

Atas ialah kandungan terperinci php如何实现弹出新页面. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel sebelumnya:php如何删除对象的属性Artikel seterusnya:如何查看php安装位置