2011-11-26 30 views
0

我有我的劇本,這部分如何將用戶重定向到引薦頁

<?php 
    else: 
?> 
    <script> 
     alert("You are not allowed to edit this CV!"); 
    </script> 

<?php 
    echo '<meta http-equiv="refresh" content="1"; url="'.$the_class->settings[0]['DomainName'].'myresume.php"'; 
    endif; 
?> 

時,被點擊的警告框彈出,並「確定」按鈕後,客觀, 用戶應被重定向到http://www.mydomain.com/myresume.php

現在問題是,在頁面加載重定向之前,警報框會一直彈出而不會到達目標頁面......如何解決這個問題?

回答

3

,如果你想一直送他們回http://www.mydomain.com/myresume.php你可以做這樣的事情:

<script> 
    alert("You are not allowed to edit this CV!"); 
    window.location.href = 'http://www.mydomain.com/myresume.php'; 
</script> 

你可以做這樣的事情,如果你不是要送他們回到他們在以前的任何頁面:

<script> 
    alert("You are not allowed to edit this CV!"); 
    history.back(); 
</script> 
+0

它工作編輯..謝謝男人 – sasori

0

問題似乎是您在發送內容後嘗試設置標題。您可以嘗試使用header function。如果這不起作用,您可以簡單地刪除alert

如果您需要顯示alert,您可以在腳本標記中添加window.location並刪除php部分。

您也可以通過使用ob_implicit_flush關閉輸出緩衝來進行實驗。

0

如何送他們回用javascript:

<?php 
    else: 
?> 
    <script> 
     alert("You are not allowed to edit this CV!"); 
     document.location = 
<?php 
     echo '"'.$the_class->settings[0]['DomainName'].'myresume.php"'; 
?> 
    ; 
    </script> 

<?php 
    endif; 
?>