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

不知道else里该写什么。点false那个选项也打开网页了。。else怎么写才能不动作?

  <script type="text/javascript">  

   function openWindow(){

    var there="http://www.imooc.com"

    var newwin=confirm("是否打开网站");

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

    if(newwin=true)

    {

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

    }

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

    else

    {   }

}

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

  </script> 


提问者:再码一段 2017-02-24 21:23

个回答

  • 慕粉1148243291
    2017-02-24 21:26:19
    已采纳

     if(newwin=true)  不是一个=号,是两个

    你改成if(newwin==true)