| | #1 |
| Warrior Member Join Date: 2012
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
Hello everyone, I have a page that i included this code <script type="text/javascript" language="javascript"> function exit() { window.open(''); } --> </script> <body onunload="exit()"> So, when someone exit from my page the pop up will appear. However, i have also one more link on that page and when i click that link the pop up appear as well. I do not want the pop up to appear when i click any other links on that page. I want the pop up to appear only when i click to exit from the page. Anybody knows any solutions? Thank you |
| |
| | #2 |
| Kevin Cornbower War Room Member Join Date: 2011 Location: Florida
Posts: 61
Thanks: 6
Thanked 62 Times in 12 Posts
|
If you're using jQuery, it's pretty easy. Code: <script type="text/javascript">
function PopIt() { return "Are you sure you want to leave?"; }
function UnPopIt() { /* nothing to return */ }
$(document).ready(function() {
window.onbeforeunload = PopIt;
$("a").click(function(){ window.onbeforeunload = UnPopIt; });
});
</script> |
| |
| | #3 |
| Active Warrior Join Date: 2012
Posts: 49
Thanks: 0
Thanked 2 Times in 1 Post
|
Hi Friend, Call the same function exit() on the that link <element onclick="SomeJavaScriptCode"> e.g. <a href="#" onclick="return exit()"> Hope this will help you. |
| |
|
| Bookmarks |
| Tags |
| pop, popup, question, questionplease |
| |