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.