Skip to content

Instantly share code, notes, and snippets.

@mbparvezme
Last active March 4, 2024 07:27
Show Gist options
  • Save mbparvezme/bd6e620447915d28b29c389fff59e76b to your computer and use it in GitHub Desktop.
Save mbparvezme/bd6e620447915d28b29c389fff59e76b to your computer and use it in GitHub Desktop.
var warnings = ["First warning!! Do not try to leave or close the window.", "Last warning!! Do not try to leave or close the window.", "Sorry!! Your account locked."];
var i = 0;
window.addEventListener("mouseout", function(e) {
if (!e.relatedTarget || e.relatedTarget.nodeName == "HTML") {
i++;
if (i <= 3) {
alert(warnings[i - 1]);
if (i == 3) {
window.location.replace("http://example.com/lock-window");
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment