0

How can I stop this event from occurring on browser refresh? Here is the code:

if ($("body").attr('onbeforeunload') == null) {
if (window.event) {
    // IE and Chrome use this
    $("body").attr('onbeforeunload', 'CatchLeavePage(event)');
    <?php

    // Log out when browser is closed
    echo "  location.href=\"/logout.php\"";

    ?>      
}

How can I stop this event from occurring on browser refresh?

1 Answers1

0

Use a cookie or local storage to store a value that you have already done what you want to do. Then if you want to do it again, just set that value to false.

pfrank
  • 2,090
  • 1
  • 19
  • 26