Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.onbeforeunload = fget;
- function yPop(url) {
- var found = 1;
- window.onbeforeunload = '';
- window.location = url;
- return false;
- }
- function fget() {
- alert("Thank you for visiting our website, you are welcome any time! nn");
- window.location = "http://NewLink.com";
- return "n________________________nn PRESS 'CANCEL' To Stay On The Current Page nn________________________n";
- }
- $(window).unload( function () { alert("Bye now!"); } );
- <html>
- <head>
- <script type="text/javascript">
- var hook = true;
- window.onbeforeunload = function() {
- if (hook) {
- return "Did you save your stuff?"
- }
- }
- function unhook() {
- hook=false;
- }
- </script>
- </head>
- <body>
- <!-- this will ask for confirmation: -->
- <a href="http://google.com">external link</a>
- <!-- this will go without asking: -->
- <a href="test.html" onClick="unhook()">internal link, un-hooked</a>
- </body>
- </html>
Add Comment
Please, Sign In to add comment