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

前端 未结 7 777
执笔经年
执笔经年 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

    None of the above solutions are works correctly. in terms of exact Center,

    I tried this , It works fine for me in chrome and firefox

    var sY = screenY;
            if (sY < 0) {
                sY = 0;
            }
            var totalScreenWidth = (screenX + window.outerWidth + sY);
            if (totalScreenWidth > screen.width) {
                totalScreenWidth = totalScreenWidth / 2;
            } else {
                totalScreenWidth = 0;
            }
            windowobj.moveTo(totalScreenWidth + ((screen.width - h) / 2), ((screen.height - h) / 2));
    

    But this also have issue if the second monitors browser is viewed half in first and another half in second.

提交回复
热议问题