# Feedback: irt.org FAQ Knowledge Base Q1316

Feedback on: irt.org FAQ Knowledge Base Q1316

Sent by Steve Longworth on June 29, 2000 at 10:16:12: - feedback #1440

Worth:

Length:
Just right

Technical:
Just right

This code does not work - it contains a spurious ' after the comma at the end of window.open line :
+','left='+leftPos)
It also seems to have the width and height round the wrong way in the line:
var topPos = (w-popW)/2, leftPos = (h-popH)/2;
I believe it should be:
var topPos = (h-poph)/2, leftPos = (w-popw)/2;

Regards
Steve

Sent by Tully Edson on July 25, 2000 at 11:47:39: - feedback #1527

The part on centering a popup inside of the browser window doesnt work right because it doesnt take into account the offset of the opener from the top left corner of the screen.

Sent by john doe on August 09, 2000 at 17:34:17: - feedback #1604

Worth:

Error in Q1316 code:
When you calculate the popup placement position based on the size of the original browser window and the popup window, you have the variables incorrectly swapped:
var topPos = (w-popW)/2, leftPos = (h-popH)/2;

It should be:
var topPos = (h-popH)/2, leftPos = (w-popW)/2;

Sent by erik Hertogs on August 11, 2000 at 08:40:09: - feedback #1618

Worth:

apparently there's an ' to much in ...','left='+leftPos);
this should be ...',left='+leftPos);

Sent by Ben Lye on January 25, 2001 at 05:40:20: - feedback #2281

Worth:

Length:
Just right

Technical:
Just right

Shouldn't the line:
"var topPos = (w-popW)/2, leftPos = (h-popH)/2;"

var leftPos = (w-popW)/2, topPos = (h-popH)/2;

The height was being divided into the horizontal and vice-versa.

Sent by Jeremy on October 10, 2001 at 09:41:20: - feedback #3233

Worth:

This script works great on most browsers, except for Netscape 6.1 for PC.

Sent by Sean McLeary on January 17, 2002 at 12:40:32: - feedback #3497

Technical:
Not technical enough

the suggested method for centering the pop-up over the browser window does not take into account the distance the browser window is separated (top and left) from the top-left-hand corner of the screen. try this instead:

function centerPopup (page)
{
var w=200, h=135, bw, bh, bl, bt, topPos, leftPos;

if (document.all)
{
bw = document.body.clientWidth;
bh = document.body.clientHeight;
bl = window.screenLeft;
bt = window.screenTop;
}
else if (document.layers)
{
bw = window.outerWidth;
bh = window.outerHeight;
bl = window.screenX;
bt = window.screenY;
}

leftPos = Math.floor((bw-w)/2) + bl;
topPos = Math.floor((bh-h)/2) + bt;

attributes = "width=" + w + ",height=" + h + ",top=" + topPos + ",left=" + leftPos;
popUpWin = window.open (page, "winName", attributes);
}

Sent by candie tan on September 17, 2002 at 22:45:12: - feedback #4158

Worth: