[英]Reloading a page won't work after calling a javaScript alert in PHP
[英]php code not executing after calling a javascript alert
我在調用javascript警報后無法執行php重定向時遇到麻煩。 代碼如下:
echo '<script>window.alert("This device is aleady registered to another user");</script>';
header('Location: page.php');
在警報上單擊“確定”后,重定向將不會執行。 關於如何使此代碼正常工作的任何想法?
謝謝
輸出后無法發送標題。 只需通過JavaScript一直重定向用戶即可。
echo '<script>window.location.href = "page.php";</script>';
在調用header
之前,您甚至無法輸出任何內容,甚至沒有一個空格。 您可以在輸出腳本之前使用標頭,如下面的代碼所示
header('Location: page.php');
echo '<script>window.alert("This device is aleady registered to another user");</script>';
希望這對您有幫助
嘗試這種方式
echo '<script>window.alert("This device is aleady registered to another user");
window.location.href = "page.php";
</script>';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.