Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

popup open position in chrome

Tags:

When I'm using firefox and then using window.open('blah.com','blah','left=-30,top=-300');, the popup opens in my second display above my first one but in chrome, the popup just opens at left=0,top=0. Is there a reason why chrome is doing this and how would I fix the problem?

Thanks!

like image 905
Andrew Avatar asked Jul 19 '11 21:07

Andrew


People also ask

How do I change the position of a pop-up window?

You can use "window. moveTo(X,Y)" to set the position of popup window.

How do I change the default pop-up window size?

In setting of a default popup window size/position for Chrome, first open an instance of a broswer. Then press on the upright "Restore" button of the opened browser(Google Chrome). Go make adjustment to desired size and position of the window for the browser. Maximize the main tabbed window of the browser.

How do I open a pop-up window?

The syntax to open a popup is: window. open(url, name, params) : url. An URL to load into the new window.


2 Answers

This is a bug in Chrome when the pop-up window is opened on the secondary monitor. The Chrome folks seem to say that this is a security issue (though how this is a security issue is beyond me).

Now, opening a pop-up window on a NON-EXISTENT secondary monitor, I could understand is a security issue, but... whatever.

Here's a link to a discussion on the matter:

https://code.google.com/p/chromium/issues/detail?id=137681

like image 98
Chris Jordan Avatar answered Sep 22 '22 00:09

Chris Jordan


I know this is an old post but here's my solution to it. Just use the "avail*" properties of the screen object:

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(http://example.com, '_blank', 'width=' + windowSize.width + ', height=' + windowSize.height + ', left=' + windowLocation.left + ', top=' + windowLocation.top); 

Basically, the "window.screen.availLeft" gives you the other screens width so you can add you're normal center calculation to that.

like image 43
Adrian Neatu Avatar answered Sep 22 '22 00:09

Adrian Neatu