如果这对其他人有帮助,我使用Better Wordpress External Links 插件并在根目录中创建一个名为exit的页面。php
在“Prefix external links with”下的插件设置中,我选择了“自定义url”,并输入-http://mysite.com/exit.php?redirect=
我还选中了“处理页面范围的链接?”
在出口内。php页面我添加了一些js来处理倒计时。
<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>
和HTML来显示倒计时并提供指向上一页的链接。
<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>