Window.open, chrome brings the window back to bring up the window screen in two-screen settings

Chrome works differently than IE and FF when opening a window with the API window.openand the left position indicated in the position on the right screen / monitor when setting up a double screen ([screen1] [screen2]).

The same thing happens when the call screen is on the right monitor, the left position always starts from the second monitor, although after opening the property it screenXcorrectly reports the width of the screen, not 0 (put this window on the second monitor and set it left=0in jsfiddle below to check this) .

Chrome seems to always snap the popup to the call window screen.

  • Chrome 41.0.2272.76 m
  • FF 36.0.1
  • IE 11.0.9600.17633

You can try this in this tiny fiddle http://jsfiddle.net/inglun/en59odar/

Of course, this is a setting so that the windows do not end on the screen, which does not take into account the second screen. Error? Is there any way around this?

In the real case, users place a window on the second screen, expecting it to end there during the next session (possibly tomorrow). Positions are saved in local storage.

+4
source share
1 answer

I found this with some search and changed it in your example ...

$(function()
{
    $('#btnOpen').click(function(){
    // change 2100 put window on right screen
    var windowSize = {
      width: 500,
      height: 500,
    };
    var windowLocation = {
        left:  (window.screen.availLeft + (window.screen.availWidth / 2)) - (windowSize.width / 2),
        top: (window.screen.availTop + (window.screen.availHeight / 2)) - (windowSize.height / 2)
    };

    window.open('about:blank', null, 'width=' + windowSize.width + ', height=' + windowSize.height + ', left=' + windowLocation.left + ', top=' + windowLocation.top)

    });
});

source: pop-up open position in chrome

0
source

All Articles