<script type="text/javascript" src="/inc/jquery-1.2.6.min.js"></script>
<script type="text/javascript">
var t= 5;//跳轉所需時間(秒)
$(function(){
redict();//5秒後頁面跳轉回主頁
});
function redict()
{
$("#showTime").html(t);
var id = window.setInterval("setTime()",1000);//setInterval方法中不能調用帶參數的方法,而且調用方法必須使用雙引號包含,否則無效。
}
function setTime()
{
t=t-1;
$("#showTime").html(t);
if(t==0)
{
$("#redictTip").html('頁面跳轉中...');
window.location="main.aspx";
}
}
</script>
html源碼中加上如下代碼以作提示:
<div id="redictTip" style="margin-top:50px; font-size:16px; color:Red; text-align:center;">請求的頁面不存在,經過<span id="showTime"></span>秒後自動跳轉回主頁</div>