Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created Sep 1, 2021
Embed
What would you like to do?
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Prevenir que usuario deje la página - By Parzibyte</title>
</head>
<body>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias placeat laborum, magni fugiat ab, rerum iure
ducimus, asperiores sequi dolores ex quos labore exercitationem vitae modi autem repudiandae pariatur earum!</p>
<script>
window.addEventListener("beforeunload", (evento) => {
if (true) {
evento.preventDefault();
evento.returnValue = "";
return "";
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment