錯誤提示頁面自動返回上一頁

<body>
    <table align="center" width="400" cellpadding="10" border="0" style="text-align:center; margin:0 auto; margin-top:100px; border:#FF6600 1px solid; font-family : Arial;font-size : 11px;color : #656565;" >
    <tr>
        <td width="50" rowspan="3" valign="top" >
            <a href="javascript:history.go(-1)"><span id="spanSeconds">10</span>seconds</a>
        </td>
    </tr>
    <tr>
        <td id="redirectionMsg" align="left">
         error message
        </td>
    </tr>
    </table>
    <script language="JavaScript">
    //等待多長時間跳轉
    var seconds = 10;
    //這就是自動跳轉的頁面地址  默認我寫成javascript:history.go(-1)  也可以寫別的地址如2.html
    var defaultUrl = "javascript:history.go(-1)";
    onload = function()
    {

      if (defaultUrl == 'javascript:history.go(-1)' && window.history.length == 0)
      {
        document.getElementById('redirectionMsg').innerHTML = '';
        return;
      }

      window.setInterval(redirection, 1000);
    }
    function redirection()
    {
      if (seconds <= 0)
      {
        window.clearInterval();
        return;
      }

      seconds --;
      document.getElementById('spanSeconds').innerHTML = seconds;

      if (seconds == 0)
      {
        window.clearInterval();
        location.href = defaultUrl;
      }
    }
</script>
</body>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章