Home  >  Article  >  Backend Development  >  How to pop up a new page in php

How to pop up a new page in php

藏色散人
藏色散人Original
2020-08-31 09:14:226894browse

How to pop up a new page in php: 1. Use the "header("Location:".PSYS_BASE_URL."user/index");" method to realize the pop-up jump; 2. Use "header("refresh: 3;url='createTag' ");".

How to pop up a new page in php

Recommendation: "PHP Video Tutorial"

PHP implements pop-up prompt box and jumps to new page

PHP realizes returning to the previous page after popping up the prompt box

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

alert contains the prompt message, and href is the page that jumps after the prompt.

If the alert is garbled in Chinese, add the following code

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

We can consider encapsulating it into a function to call. The following is my own encapsulated page jump function

/**
* 页面跳转方法
* @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;
}

How to use: messageInfo('Operation successful!','http://www.demourl.com/product_list.php');

Other jump methods

The code is as follows:

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

$url is the page to be jumped. At the same time, this can also control the jump time. The 0 after content means that the page will jump after 0 seconds.

Two direct jump methods:

The code is as follows:

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

The code is as follows:

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

The above is the detailed content of How to pop up a new page in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn