PHP弹出提示框后跳转
一个PHP写好的弹出提示框后跳转的函数
/**
* Send http request to back location,需要2次请求
*
* @param string $alert the alert message
* @param string $url default is TMConfig::Domain
* @return string $content
*/
public function sendAlertBack($alert = "", $url="") {
if (!emptyempty($alert)) {
$alertstr = "alert('" . $alert . "');n";
} else {
$alertstr = "";
}
if (emptyempty ($url)) {
$gotoStr = "window.history.back();n";
} else {
$gotoStr = "window.location.href='" . $url . "'n";
}
$content = "t<script language=javascript>nt<!--n";
if (!emptyempty($alertstr)) {
$content .= $alertstr;
}
if($url != "NONE") {
$content .= $gotoStr;
}
$content .= "t-->nt</script>n";
return $content;
}
简单的
echo "<script>alert('恭喜!申请成功,请等待审核。');location.href='friendlist.php';</script>";