求大神指导,请问为什么点击按钮没反应?

来源:2-7 编程练习

weixin_慕仙7528819

2019-07-24 16:45

<!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 open=confirm("Do you wanna open imooc in new window?");        // 新窗口打开时弹出确认框,是否打开        if(open==true){            var url=prompt("comfirm the website", "http://www.imooc.com/");        }        // 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/        if(url!=null){            window.open('url', '_blank', 'width=400, height=500, meanubar=no, toolbar=no');        }        //打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。        else{            alert("Fail");        }        else{            alert("Fail");        }                    }                </script>  </head>  <body> 	 <input type="button" value="新窗口打开网站" onclick="openWindow()" />  </body></html>


写回答 关注

2回答

  • 慕妹6067522
    2019-07-24 22:45:05
    已采纳

    你对比下你写的那个,应该包含的关系,你这个写成并列了。

    <!DOCTYPE html><html> 

    <head>  

    <title> new document </title>    

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>     

    <script type="text/javascript">      

    function openWindow(){        

    var open=confirm("Do you wanna open imooc in new window?");        

    // 新窗口打开时弹出确认框,是否打开        

    if(open==true)

    {            

    var url=prompt("comfirm the website", "http://www.imooc.com/"); 

    url_1 = "http://www.imooc.com/"

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

    if(url!=null)

    {            

    window.open(url_1, '_blank', 'width=400, height=500, meanubar=no, toolbar=no');        

    }        

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

    else

    {            

    alert("Fail");        

    }        

    }

    </script>  

    </head>  

    <body>    

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

    </body>

    </html>


  • weixin_慕仙7528819
    2019-08-02 18:01:36

    感谢感谢!


JavaScript入门篇

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

738662 学习 · 9561 问题

查看课程

相似问题