为了账号安全,请及时绑定邮箱和手机立即绑定

if(变量名!==null)是什么意思呢?不是应该confirm后直接window.open么?

<!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 url=confirm("是否打开网页?");

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

      if(url==true)

      {var pp=prompt("http://www.imooc.com/");

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

         if(pp!==null)

         {window.open('http://www.imooc.com/','_blank','width=400px,height=500px,manubar=no,toolbar=no');}

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

       }

      else{alert("好好难");}

   } 

  </script> 

 </head> 

 <body> 

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

 </body>

</html>


正在回答

2 回答

!== 就是不相等 null 就是空的意思

设置if( !==null) 就是为了取消也不会打开网站

1 回复 有任何疑惑可以回复我~

 function openWindow()

    {

     var url=confirm("是否打开网页?");

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

     if(url==true){

          var pp=prompt("请输入要打开的网址",“http://www.imooc.com”);

          // 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/                                                            window.open(pp,'_blank','width=400px,height=500px,manubar=no,toolbar=no');

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

    }

      else{alert("好好难");}

   } 


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

if(变量名!==null)是什么意思呢?不是应该confirm后直接window.open么?

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信