window.open() on a multi-monitor/dual-monitor system - where does window pop up?

前端 未结 7 749
执笔经年
执笔经年 2020-11-29 23:03

When using javascript window.open() on a multi-monitor system, how do you control which monitor, or where in the display space the popup opens? It seems out of control to me

相关标签:
7条回答
  • 2020-11-29 23:50
    /**
     * Display popup window in the center of the screen.
     */
    function popupWindow(url, title, w, h) {
      // Use window.screenX to center the window horizontally on multi-monitor 
      // setup. 
      var left = window.screenX + (screen.width / 2) - (w / 2);
      var top = (screen.height / 2) - (h / 2);
      return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
    },
    
    0 讨论(0)
提交回复
热议问题