DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> 網站404頁面3秒後跳到首頁的實例代碼
網站404頁面3秒後跳到首頁的實例代碼
編輯:關於JavaScript     
復制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>404 Not Found</title>
</head>
<body>
 <h1>找不到指定的頁面</h1>
 <span id="totalSecond">3</span>秒後自動返回
</body>
<script language="javascript" type="text/javascript">
<!--
    var second = document.getElementById('totalSecond').textContent;
    if (navigator.appName.indexOf("Explorer") > -1)  //判斷是IE浏覽器還是Firefox浏覽器,采用相應措施取得秒數
    {
        second = document.getElementById('totalSecond').innerText;
    } else
    {
        second = document.getElementById('totalSecond').textContent;
    }
    setInterval("redirect()", 1000);  //每1秒鐘調用redirect()方法一次
    function redirect()
    {
        if (second < 0)
        {
            location.href = 'http://要跳轉的網站';
        } else
        {
            if (navigator.appName.indexOf("Explorer") > -1)
            {
                document.getElementById('totalSecond').innerText = second--;
            } else
            {
                document.getElementById('totalSecond').textContent = second--;
            }
        }
    }
-->
</script>
</html></td>
   </tr>
 </table>
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved