4

Chrome behaves differently than IE and FF when opening a window with API window.open and left position specified to a position on the right screen/monitor in a dual screen setup ([screen1][screen2]).

The same happens when the invoking screen is on the right monitor, the left position always starts in the second monitor, although after opening the property screenX correctly reports the screen width and not 0 (put this window in the second monitor and set left=0 in the jsfiddle below to test this).

It seems that Chrome always snaps the popup position to the invoking window screen.

  • Chrome 41.0.2272.76 m
  • FF 36.0.1
  • IE 11.0.9600.17633

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

For sure, it is an adjustment to prevent windows to end up off screen that fails to take second screen into account. Bug? Is there a way around this?

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

Lukas Kabrt
  • 5,441
  • 4
  • 43
  • 58

1 Answers1

0

I found this with some searching and modified it per 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 is: popup open position in chrome

Community
  • 1
  • 1
Sergio S
  • 194
  • 7