how to create site exit messages with destination url displayed

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>