Centered effect popup not working in Chrome

I have a website that I created a while ago. Suddenly, without changing the code, the centered popup has now lost its size and center alignment and is positioned in the upper left corner by about 50 x 50 pixels!

Does anyone know what caused this? Google Chrome changed something that affected my script? It still works in all other browsers and has only recently been used to work in Chrome.

My caller:

onclick="wOpen('', 'preview', 800, 500); return false;"


My function

function wOpen(url, name, w, h) {
  w += 32;
  h += 96;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;

  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;

  var win =,
  'width=' + w + ', height=' + h + ', ' +
  'left=' + wleft + ', top=' + wtop + ', ' +
  'location=no, menubar=no, ' +
  'status=no, toolbar=no, scrollbars=yes, resizable=no');
  win.resizeTo(w, h);
  win.moveTo(wleft, wtop);


Any suggestions?


source to share

2 answers

There seems to be something wrong with resizeTo () and moveTo () in chrome.

Usually chrome should ignore these methods, but now they are executed somehow and the window is moved to an unknown location and gets an unknown size.

I can't see the window at all, but in the taskbar I can see that it must be somewhere, I can also maximize it.

Suggestion: Make a condition so that no lines are executed in chrome.

Better Suggestion: Don't use these methods at all.

Also see: javascript "resizeTo" function not working in Chrome and Opera



There is an issue in new Chrome version



All Articles