2016-08-28 79 views
-5

在此代碼中,警告框不起作用。我想重定向頁面並使用alertbox顯示一條消息。我該如何解決它?Javascript alert and back with php

if($stmt){ 
?> 
    <script type="text/javascript"> 
     alert("Package Successfully Booked.."); 
    </script> 
<?php 
header("location:javascript://history.go(-1)"); 
} 
?> 
+0

然後把history.go呼叫警報後,而不是試圖把它的標題(這是無意義的BTW)。 –

+0

http://stackoverflow.com/questions/11869662/display-alert-message-and-redirect-after-click-on-accept – soundslikebliss

+0

這裏,重定向頁面是固定的。重定向( '管理員/ AHM /面板'); 。但我沒有固定頁面 – Pavel

回答

0

您可以使用Windows加載函數提醒用戶。

window.onload = function() { 
    alert('Package Successfully Booked!'); 

}

,或者你可以這樣來做

<html> 
 
<head> 
 
<script> 
 
function showAlert() 
 
    { 
 
    alert("Package Successfully Booked!"); 
 
    } 
 
    </script> 
 
</head> 
 
<body onload="showAlert()"> 
 
</body> 
 
</html>