how to create site exit messages with destination url displayed

i’m looking for a way to show an exit page or message when a user leaves my site. we have a uk version of our site, and some of the nav links lead back to our us site. i want to let users know that they are leaving the uk site and “are now being redirected to this page at our us site. you will be redirected in 10 seconds, or click here to stay” etc.

i’ve seen a few plugins that can do this, but is seems like the only redirect to one page, and they don’t tell the user where they’re going – just that they are leaving the site.

Read More

are there any plugins that can handle this, or is it something i have to create from scratch? if the latter, where do I start?

thanks so much!

Related posts

Leave a Reply

1 comment

  1. In case it helps anyone else, i worked out how to do this using the Better WordPress External Links plugin and creating a page in root called exit.php

    in the plugin settings under “Prefix external links with” i chose “a custom url” and entered – http://mysite.com/exit.php?redirect=

    I also checked the box next to “Process page-wide links?”

    Inside the exit.php page i added some js to handle the countdown.

    <script>
    
          // Parse the query string to get the destination URL
          var params = {};
          var pairs = window.location.search.substring(1).split('&');
          for (var i = 0; i < pairs.length; i++) {
              var components = pairs[i].split('=');
              params[components[0]] = decodeURIComponent(components[1]);
          }
    
          setTimeout(function() { window.location = params.redirect; }, 5000);
    </script>
    
    
    <script>
    
        $(function(){
      var count = 5;
      countdown = setInterval(function(){
        $(".countdown").html(count);
    
        count--;
      }, 1000);
    });
    
    </script>
    

    and the HTML to display the countdown and provide a link to the previous page.

    <p>You will be redirected in <span class="countdown" style="font-weight:bold;"></span> seconds.</p>
    <p><a href="#" onClick="history.go(-1);return false;">If you would like to remain on this site, click here.</a></p>