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

请看看我这个怎么回事?

<!DOCTYPE HTML>

<html>

    <head>

        <script>

            var sum=5;

           function acc(){

              

               document.getElementById("con").value=sum;

                if(sum=0){

                   window.history.go(-1);

               }

               sum=sum-1;

               var i=setInterval("acc()",1000);

               }

              

            function abb(){

                window.history.back();

            }

            </script>

        </head>

        <body>

            <h1>操作成功</h1><br />

            <input type="text" id="con" value=5> <h2>秒后回到主页</h2><input type="button" value="返回" onclick="abb()" />

            </body>

    </html>

   


提问者:慕前端0798377 2018-08-22 13:38

个回答

  • 若水寒
    2018-08-23 10:46:00

    没有调用函数acc()

     修改部分:

    1.<body onload="acc()">

    2. function acc(){

                 document.getElementById("con").value=sum;

                   sum--;

                    if(sum>0){

                       var i=setTimeout("acc()",1000);

                   }

    else{

    window.open('https://www.imooc.com','_self');

    }

                   


                  


                   }