Last active
June 5, 2020 06:41
-
-
Save sonichandni/5cd2d1f54e1ea935095c9e9ec279b91f to your computer and use it in GitHub Desktop.
redirect a page to another page when refresh at second attempt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
submitFormOkay = false; | |
$(document.body).on("click", "a", function() { | |
submitFormOkay = true; | |
}); | |
window.onbeforeunload = function(event) { | |
event.preventDefault(); | |
if (!submitFormOkay) { | |
window.setTimeout(function () { | |
window.location = "{!!LaravelLocalization::localizeURL('/dashboard')!!}"; | |
}, 0); | |
window.onbeforeunload = null; // necessary to prevent infinite loop, that kills your browser | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment