PHP弹出提示框后跳转

php教程11年前 (2014-08-27)13630

一个PHP写好的弹出提示框后跳转的函数

  1. /**   

  2.      * Send http request to back location,需要2次请求   

  3.      *   

  4.      * @param string $alert             the alert message   

  5.      * @param string $url               default is TMConfig::Domain   

  6.      * @return string $content   

  7.      */     

  8.     public function sendAlertBack($alert = "", $url="") {     

  9.         if (!emptyempty($alert)) {     

  10.             $alertstr = "alert('" . $alert . "');n";     

  11.         } else {     

  12.             $alertstr = "";     

  13.         }     

  14.          

  15.         if (emptyempty ($url)) {     

  16.             $gotoStr = "window.history.back();n";     

  17.         } else {     

  18.             $gotoStr = "window.location.href='" . $url . "'n";     

  19.         }     

  20.          

  21.         $content = "t<script language=javascript>nt<!--n";     

  22.         if (!emptyempty($alertstr)) {     

  23.             $content .= $alertstr;     

  24.         }     

  25.          

  26.         if($url != "NONE") {     

  27.             $content .= $gotoStr;     

  28.         }     

  29.         $content .= "t-->nt</script>n";     

  30.          

  31.         return $content;     

  32.     } 



简单的

  1. echo "<script>alert('恭喜!申请成功,请等待审核。');location.href='friendlist.php';</script>";


发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。