问答详情
源自:8-17 编程练习

代码可以跑起来:)

<!DOCTYPE html>

<html lang="en">


<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <title>Document</title>

</head>


<body>

    <h1>操作成功</h1>

    <span>5</span>

    <span>秒后回到主页 </span>

    <span><input type="button" id="back" value="返回" /></span>

    <script type="text/javascript">

        var c = 5;

        function count() {

            document.querySelectorAll("span")[0].innerHTML = c;

            --c;

            if (c == 0) {

                window.open("http://www.imooc.com/", "_blank");

            }

            window.setTimeout("count()", 1000);

        }

        count();

        document.querySelector("#back").addEventListener("click", function () { window.history.go(-1); }, true);

    </script>

</body>


</html>


提问者:Gan干 2019-09-25 13:37

个回答

  • Cover_For
    2019-10-13 12:55:32
    已采纳

    566666