Pop-Up Question-Please Help

by 2 replies
3
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
#programming #pop #popup #question #questionplease
  • 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.
  • 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.

Next Topics on Trending Feed