问答详情
源自:2-5 JavaScript-打开新窗口(window.open)

为什么不能打开新窗口

<!DOCTYPE HTML>

<html>

<head>

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

<title>window.open</title>

<script type="text/javascript">

  function Wopen(){

    window.open([http://www.imooc.com],[_blank],[width:600px;height:400px;top:100px;left:0;])  


  } 

</script>

</head>

<body>

    <input name="button" type="button" onClick="Wopen()" value="点击我,打开新窗口!" / >

</body>

</html>


提问者:qq_自律_0 2016-04-28 21:18

个回答

  • 一骑红尘妃子笑
    2016-05-18 10:18:21

    window.open([http://www.imooc.com],[_blank],[width:600px;height:400px;top:100px;left:0;]) 

    不用【】,用''

  • suiye1202
    2016-05-01 20:26:44

    <!DOCTYPE HTML>

    <html>

    <head>

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

    <title>window.open</title>

    <script type="text/javascript">

      function Wopen(){

        window.open('http://www.imooc.com','_blank','width:600px,height:400px,top:100px,left:0;')  


      } ;

    </script>

    </head>

    <body>

        <input name="button" type="button" onClick="Wopen()" value="点击我,打开新窗口!" / >

    </body>

    </html>


  • 慕粉3253576
    2016-04-28 21:58:37

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>window.open</title>
     <script type="text/javascript">  
        function openWindon(){
            if(confirm("确定打开新窗口吗?")){
                var url = prompt("请输入一个网址","http://www.imooc.com/");  
                window.open( url,"_blank","toolbar=no, menubar=no, scrollbars=yes,  width=400, height=400");
            }
        }  
     </script>
    </head>
    <body>
      <input type="button" value="新窗口打开网站" onclick="openWindon()" />
    </body>
    </html>

  • qq_自律_0
    2016-04-28 21:28:07

    <!DOCTYPE HTML>

    <html>

    <head>

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

    <title>window.open</title>

    <script type="text/javascript">

      function Wopen(){

        window.open("http://www.imooc.com","_blank","width:600px;height:400px;top:100px;left:0;")  


      } 

    </script>

    </head>

    <body>

        <input name="button" type="button" onClick="Wopen()" value="点击我,打开新窗口!" / >

    </body>

    </html>

    用引号括起来