调用javascript警报后未执行php代码
我在调用javascript警报后执行php重定向时遇到了一些问题。代码如下:调用javascript警报后未执行php代码,javascript,php,redirect,Javascript,Php,Redirect,我在调用javascript警报后执行php重定向时遇到了一些问题。代码如下: echo '<script>window.alert("This device is aleady registered to another user");</script>'; header('Location: page.php'); echo'window.alert(“此设备已向其他用户注册”); 标题('Location:page.php'); 单击警报上的“确定”后,将不执行
echo '<script>window.alert("This device is aleady registered to another user");</script>';
header('Location: page.php');
echo'window.alert(“此设备已向其他用户注册”);
标题('Location:page.php');
单击警报上的“确定”后,将不执行重定向。关于如何让代码正常工作,有什么想法吗
谢谢您不能在输出后发送标题。只需通过javascript一路重定向用户即可
echo '<script>window.location.href = "page.php";</script>';
echo'window.location.href=“page.php”;
在调用标题之前,您不能输出任何内容,甚至不能输出一个空格。您可以在输出脚本之前使用header,如下面的代码所示
header('Location: page.php');
echo '<script>window.alert("This device is aleady registered to another user");</script>';
header('Location:page.php');
echo“window.alert”(“此设备已向其他用户注册”);
希望这对您有所帮助这是您可以使用的最好方法:-
窗口位置
试试这种方法
echo '<script>window.alert("This device is aleady registered to another user");
window.location.href = "page.php";
</script>';
echo'窗口。警报(“此设备已向其他用户注册”);
window.location.href=“page.php”;
';
请检查我的答案