1

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.

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!

1 Answer 1

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.