问答详情
源自:2-7 编程练习

请问一下我这段代码那里出错了,点击按钮时没有反应

<!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 asure=confirm("是否打开新窗口");

        if(asure==true){

            var url = prompt("请输入网址","http://www.imooc.com");

            if(url!=null && url != ""){

                window.open('http://www.imooc.com','_blank','width=300,height=200,menubar=no,toolbar=no, );        }

            else if(url == ""){

                alert("网址不能为空");

            }

            else{

                alert("请输入网址");

            }

        }

        else{

            alert("用户取消打开新窗口");

        }

        }

    // 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/


    //打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。

    

    

  </script> 

 </head> 

 <body> 

 <input type="button" value="新窗口打开网站" onclick="openWindow()" /> 

 </body>

</html>


提问者:慕先生2816655 2015-10-17 20:27

个回答

  • Perona
    2015-10-17 20:36:34
    已采纳

    window.open('http://www.imooc.com','_blank','width=300,height=200,menubar=no,toolbar=no, );        }

    这一行最后缺了单引号

    window.open('http://www.imooc.com','_blank','width=300,height=200,menubar=no,toolbar=no, ');        }