Page doesn’t reload while alert is present

When I try to reload page from browser it will close alert message, but next the one will appear.
Therefore, I can never reload the page.

Page minimal example:

<script type="text/javascript">
  alert(1);
</script>
<body>
  12312312313123
</body>
<script type="text/javascript">
  function alertLOL(){
    alert("LOL")
    alertLOL();
    return;
  }
  alertLOL();
</script>

Does anyone know how to resolve this issue? On my page I have a similar recursive code for logining.

  • Why would would you even use alert in the first place? If you cannot remove the alerts, you can rewrite window.alert

    – 

you have to click 5-10 time on the reload button.
And that’s a bad idea to use alert, you can use SweetAlert 2 (swal2) here is the website Swal website

That’s simple and you can personnalise.
Here is a simple code :

Swal.fire({
  title: "Good job!",
  text: "You clicked the button!",
  icon: "success"
});
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>

Leave a Comment