求大神帮我看看哪错了

来源:2-7 编程练习

慕丝8472657

2018-08-17 11:27

<!DOCTYPE html>
<html>
 <head>
  <title> new document </title> 
  <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>   <script type="text/javascript"> 
    function openWindow()
    {
    var a00=confirm("是否新建窗口网站") ;
    if(a00==true)
    {
        var b11=prompt("确认网址","http//www.imooc.com/");
        if(b11==null)
        {
            window.open('http//www.imooc.com/','_blank','width=400px,heught=500px,menubar=no,toolbar=no');
        }
        else{
            document.write("错误");
        }
           
     }
        else{
            document.write("错误");
        }
    }
    </script>
 </head>
 <body>
   <input type="button" value="新窗口打开网站" onclick="openWindow()" />
 </body>
</html>

写回答 关注

1回答

  • lp林大大
    2018-08-17 12:29:44
    已采纳

    正解:if(b11!=null)

        {
              window.open ('_blank','width=400px,heught=500px,menubar=no,toolbar=no');
            }

    两个错误,第一:当不输入时,因为第二参数已赋值,确认后直接跳转默认网页,取消则返回为null。第二window.open第一参数为网页路径,可为空或不写。

    慕丝8472...

    非常感谢!

    2018-08-17 14:59:53

    共 1 条回复 >

JavaScript入门篇

JavaScript做为一名Web工程师的必备技术,本教程让您快速入门

738661 学习 · 9561 问题

查看课程

相似问题