Home  >  Article  >  Backend Development  >  PHP implements a prompt box similar to alert() in js, jsalert_PHP tutorial

PHP implements a prompt box similar to alert() in js, jsalert_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:02:51811browse

PHP implements a prompt box similar to alert() in js. jsalert

is mainly used to add judgment prompts, jumps, returns, and refreshes.

Copy code The code is as follows:
/**
* JS prompt jump
* @param $tip Pop-up window prompt information (empty, no prompt)
* @param $type Set type close = close, back = return, refresh = prompt to reload, jump prompt and jump url
* @param $url Jump url
​*/
function alert($tip = "", $type = "", $url = "") {
$js = "<script>";<br> If ($tip)<br> $js .= "alert('" . $tip . "');";<br> switch ($type) {<br>           case "close" : //Close the page<br>                $js .= "window.close();";<br>              break;<br>          case "back" : //Return<br>                 $js .= "history.back(-1);";<br>              break;<br>          case "refresh" : //Refresh<br>                 $js .= "parent.location.reload();";<br>              break;<br> ​​​​case "top": //Frame exit<br>                  if ($url)<br> $js .= "top.location.href='" . $url . "';";<br>              break;<br>          case "jump" : //Jump<br>                  if ($url)<br> $js .= "window.location.href='" . $url . "';";<br>              break;<br>              default:<br>              break;<br> }<br> $js .= "</script>";
echo $js;
If ($type) {
exit();
}
}

The above is the entire content of this article. I hope it will be helpful to everyone learning php.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969491.htmlTechArticlePHP implements a prompt box similar to alert() in js. jsalert is mainly used to add judgment prompts, jumps, and returns. refresh. Copy the code. The code is as follows: /** * JS prompt jump * @param $tip pop-up window...
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