1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Exit Redirect?

Discussion in 'HTML & JavaScript' started by duzkerotzki, Oct 23, 2012.

  1. duzkerotzki

    duzkerotzki Regular Member

    Joined:
    Apr 18, 2009
    Messages:
    405
    Likes Received:
    308
    Occupation:
    student
    Location:
    somewhere in europe
    Hey, I need a exit redirect script that actually works. This is the script I found:
    Unfortunately this also redirects if I'm clicking on a external link on my website. And I'm forced to use external links. Is there a possibility to make it work only when they exit the website, and not if they click on an external link? I'm no coder, please help me. Thanks. duzkerotzki
     
  2. sockpuppet

    sockpuppet Junior Member

    Joined:
    Nov 7, 2011
    Messages:
    155
    Likes Received:
    145
    you could use something like this to remove the onbeforeunload handler if a link is clicked:
    Code:
    <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
    <script>
    
    $(document).ready(function() {
    	$('a').click(function(e){
    		window.onbeforeunload = null;
    		return true;
    	});
    });
    </script>
    
    btw your redirect doesn't work with chrome
     
    • Thanks Thanks x 1