您的位置:首页 > 编程语言

5秒后自动跳转的错误页面代码

2018-02-22 16:03 260 查看
新建一个Error.html页面
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    出现异常了,5秒以后自动跳转到首页。
    <span id="totalSecond">5</span>
    <script type="text/javascript">
        var second = document.getElementById('totalSecond').textContent;
        if (navigator.appName.indexOf("Explorer") > -1) {
            second = document.getElementById('totalSecond').innerText;
        } else {
            second = document.getElementById('totalSecond').textContent;
        }
        setInterval("redirect()", 1000);
        function redirect() {
            if (second < 0) {
                location.href = '/Home/Index';
            } else {
                if (navigator.appName.indexOf("Explorer") > -1) {
                    document.getElementById('totalSecond').innerText = second--;
                } else {
                    document.getElementById('totalSecond').textContent = second--;
                }
            }
        }
    </script>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: