通过 JS 实现错误页面在指定的时间跳到主页

<!DOCTYPE html>
<html>

<head>
    <title>浏览器对象</title>
    <!-- 通过 JS 实现错误页面在指定的时间跳到主页 -->
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
</head>

<body>
<!-- 先编写好网页布局 -->
<h3>操作成功</h3>
<p><b >返回</a></p>
<script type="text/javascript">
    // 获取显示秒数的元素,通过定时器来更改秒数。
    var sec = document.getElementById("second");
    var i = 5;
    var timer = setInterval(function () {
            i--;
            sec.innerHTML = i;
            if (i === 1) {
                window.location.href = "http://baidu.com";
            }
        },
        1000);

    // 通过 window 的 location 和 history 对象来控制网页的跳转。
    function goBack() {
        window.history.go(-1);
    }
</script>
</body>

</html>

相关文章:

  • 2021-05-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-13
  • 2022-12-23
  • 2022-02-19
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-17
  • 2021-10-13
  • 2022-12-23
  • 2021-05-06
相关资源
相似解决方案