Created
May 26, 2012 08:14
-
-
Save prodis/2792892 to your computer and use it in GitHub Desktop.
JavaScript exit page confirmer object
This file contains hidden or 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
Um objeto JavaScript para confirmar se o usuário quer sair da página | |
http://prodis.blog.br/2010/11/29/um-objeto-javascript-para-confirmar-se-o-usuario-quer-sair-da-pagina/ |
This file contains hidden or 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
function ExitPageConfirmer(message) { | |
this.message = message; | |
this.needToConfirm = false; | |
var myself = this; | |
window.onbeforeunload = function() { | |
if (myself.needToConfirm) { | |
return myself.message; | |
} | |
} | |
} |
This file contains hidden or 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
<html> | |
<head> | |
<script src="scripts/Prodis.ExitPageConfirmer.js"></script> | |
<script> | |
var exitPage = new ExitPageConfirmer("My confirmation message."); | |
</script> | |
</head> | |
<body> | |
<form onsubmit="exitPage.needToConfirm = false;"> | |
<p><input type="text" onchange="exitPage.needToConfirm = true;" /></p> | |
<p><input type="submit" /></p> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Valeu cara vou tentar colocar no meu site http://www.trabalhoemcasalucrativo.com e no http://www.codigosparablog.com.br
depois se possível visualize alguns dos sites acima para que possa me informar se o código está correto.
Agradeço...