Pop-Up Question-Please Help

2 replies
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
#pop #popup #question #questionplease
  • Profile picture of the author flashisland
    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>
    Code is from A Working Exit Popup » KBeezie.
    {{ DiscussionBoard.errors[6424501].message }}
  • Profile picture of the author eluminousdev
    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.
    {{ DiscussionBoard.errors[6426498].message }}

Trending Topics