如果用户未登录,我试图在登录时自动重定向之前设置 sweetalert2,但它只出现一秒钟并立即开始重定向,我如何设置等待用户点击?
我的实际代码:
<?php
session_start();
if ($_SESSION[logged] != 'yes') {
echo '
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<link rel="stylesheet" href="stylesheets/sweetalert2.css">
<script src="javascripts/custom/sweetalert2.min.js"></script>
<script>
$( document ).ready(function() {
swal("Oops...", "Not logged!", "error");
document.location.href="/login.html"
});
</script>';
exit;
}
?>