请问错在哪里

来源:1-14 编程练习

qq_Dxf_0

2017-12-30 18:30:13

<!DOCTYPE html>

<html>

    <head>

        <meta charset="UTF-8">

        <title>打开/关闭页面</title>

    </head>

    <body>

       <input type="button" name="" value="打开页面">

       <script type="text/javascript">

        var open=document.getElementsByTagName('input')[0];

        open.onclick=function(){

          var bb=window.confirm("确定打开网页吗");

          if(bb!=false){

            window.open("http://www.imooc.com","na","width=300px,height=300px,top=200px,left=600px,toolbar=no,menubar=no,scrollbars=no,location=no,status=no");

          }else{

            window.close();

          }

        }

       </script>

    </body>

</html>


写回答

1回答

Rainbow1206

2017-12-30

呵呵。

var open=document.getElementsByTagName('input')[0];   为什么偏偏把变量的名字叫做open呢?

下面window.open的时候,找到的是你自己定义的这个全局变量,不是window的open方法了,会报错这个不是一个函数。

0
hq_Dxf_0
h 好了 弄明白了 谢谢
h017-12-30
共2条回复

0 学习 · 36712 问题

查看课程