使用meta实现页面自动跳转

代码:<meta http-equiv="refresh" content="10; url=blog/">

说明:10秒钟后自动跳转到blog子目录,比如在首页http://www.lordong.net上使用上面这句可以自动跳转到/wp/

实现倒计时脚本:
<script type="text/javascript">
var m_timeout = 10;

function timeOut() {
m_timeout--;

if (m_timeout >= 0)  {
document.getElementById("timeout").innerHTML = m_timeout;
}
}
</script>

启动倒计时代码:
<body onload="setInterval('timeOut()', 1000);">

显示倒计时脚本:
<span id="timeout">10</span> 秒钟后自动跳转到 <a href="blog/">LorDong's Blog</a>

当然也可以在timeOut()函数里在m_timeout计时为<0时使用location.href='blog/'来替换自动跳转的meta代码。

Leave a Reply


提醒: 评论者允许使用'@user空格'的方式将自己的评论通知另外评论者。例如, ABC是本文的评论者之一,则使用'@ABC '(不包括单引号)将会自动将您的评论发送给ABC。请务必注意user必须和评论者名相匹配(大小写一致)。