0

When using window.open() to open a popup window, the popup window is opening slightly to the right of the window I am opening the popup from. It lines up directly left with the body when margin is not removed but I have set my css like so:

body{
  margin: 0px;
  padding: 0px;
}

I have also tried to set left=0px in my window.open function.

Here's my JS code:

var windowSize = "width=" + window.innerWidth + ",height=" + window.innerHeight + ",left=0px";
window.open('http://www.google.com/', 'popup', windowSize);

Anyone know why this is occuring? Is there any solution to alleviate this problem?

Here's my jsfiddle.

UPDATE

Here you can see that you can see some red to the left of the popup:

enter image description here

Anthony
  • 1,439
  • 1
  • 19
  • 36
  • 1
    So where do you want it now?Right or left? – vijayscode Jun 01 '17 at 20:03
  • I want it to line up all the way to the left of the window I am opening it from but there seems to be a slight "margin". – Anthony Jun 01 '17 at 20:05
  • When you set `left=0px` it aligns the window 0px offset from the left. Your fiddle shows no margin on my end. – Reed Jun 01 '17 at 20:06
  • Your fiddle is working fine. It is aligned to the left with no margin. – vijayscode Jun 01 '17 at 20:09
  • That's strange. It's not working for me. Please see my update. – Anthony Jun 01 '17 at 20:16
  • Perhaps it has to do how Chrome treats focus and popups? This user seems to have perhaps found a [possible workaround](https://stackoverflow.com/questions/4068373/center-a-popup-window-on-screen)? – Reed Jun 01 '17 at 20:22
  • I using 3 screens, same fiddle works fine in 2 screens, but popup aligned to the right on 3rd. I using Windows 7 & chrome. – Oleg Imanilov Jun 01 '17 at 20:34
  • I'm using dual monitors and on both screens there is a slight "margin". I'm using windows 10 and have tested on chrome and firefox. – Anthony Jun 01 '17 at 20:37

0 Answers0