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

给个居中打开新窗口的例子

function Wopen(){

      var newHeight = 400;

      var newWidth = 600;

      var height = (window.screen.height-newHeight)/2;

      var width = (window.screen.width-newWidth)/2;

      window.open('http://www.imooc.com','_blank','width='+newWidth+',height='+newHeight+',top='+height+',left='+width+',menubar=no,toolbar=no, status=no,scrollbars=yes');


  } 


提问者:showmylifeqwe11 2019-01-04 15:09

个回答

  • 木子955
    2019-01-04 20:19:05

    <script>

    var answer  = confirm("是否要打开新窗口?");

    var newHeight = window.screen.height/2;

    var newWidth = window.scree.width/2;

    if(answer){

     window.open("http://www.imooc.com","_blank","width=newWidth,height=newHeight");

    }

    </script>