为什么不能打开新窗口

来源:2-5 JavaScript-打开新窗口(window.open)

qq_自律_0

2016-04-28 21:18

<!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>


写回答 关注

4回答

  • 一骑红尘妃子笑
    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>

    用引号括起来


JavaScript入门篇

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

738661 学习 · 9561 问题

查看课程

相似问题