怎么打不开啊 哪里错了。。

来源:2-7 编程练习

qq_我叫酸奶_0

2017-09-07 20:34

 function openWindow(){

       var mychar=confirm("是否要打开新网址?");

       if(mychar==true){

           var url=prompt("确定打开的网址","http://www.imooc.com/");

           if (url!=null){

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

           }

          

       }

       else

       {alert("再见");}

   }


写回答 关注

3回答

  • aifun
    2017-09-07 21:16:14

    你的分号和冒号都是中文符的

  • aifun
    2017-09-07 21:13:19

    <!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 a = confirm("是否打开?");// 新窗口打开时弹出确认框,是否打开

       if(a==true){
           window.open("http://www.imooc.com/","_blank","width=400px,hight=500px,menubar=no,toolbar=no");
       }// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/

       }//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
       
       
     </script>
    </head>
    <body>
        <input type="button" value="新窗口打开网站" onclick="openWindow()" />
    </body>
    </html>

  • apianmuse
    2017-09-07 21:06:02

    不用prompt,直接window.open就行了

JavaScript入门篇

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

738244 学习 · 9560 问题

查看课程

相似问题