更改PHP标头/位置之前未发生JS警报

时间:2019-05-29 08:51:08

标签: php redirect alert

这是一个有趣的... 我正在尝试测试某些内容,然后显示 *The QR code image for each user is provided from our API and set on lock screen by the user. *The purpose of the camera permission is to scan the QR code. *The Scanned QR code returns the details uploaded by the user whose phone is lost. A demo video is attached on attachment. ,然后单击“确定”,然后使用alert将页面重新定位到其他位置。 但是,如果下面有代码,则直接转到URL。 如果我将header注释掉,那么header就会起作用。...

alert

1 个答案:

答案 0 :(得分:0)

您可以改用元重定向。我不确定这是好事还是坏事,但是它将为您解决问题。

if (...) {
    // ...
} elseif ($user['archived']=="1") {
    echo '<meta http-equiv="refresh" content="10; URL=someurl">';'
    echo "<script type='text/javascript'>alert('Sorry you are no longer an owner');</script>";
    exit;
}