Feedback on: irt.org FAQ Knowledge Base Q1316
Worth:
Worth reading
Length:
Just right
Technical:
Just right
Comments:
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
Comments:
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.
Worth:
Very worth reading
Comments:
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;
Worth:
Worth reading
Comments:
apparently there's an ' to much in ...','left='+leftPos);
this should be ...',left='+leftPos);
Worth:
Very worth reading
Length:
Just right
Technical:
Just right
Comments:
Shouldn't the line:
"var topPos = (w-popW)/2, leftPos = (h-popH)/2;"
actually read:
var leftPos = (w-popW)/2, topPos = (h-popH)/2;
The height was being divided into the horizontal and vice-versa.
Worth:
Worth reading
Comments:
This script works great on most browsers, except for Netscape 6.1 for PC.
Technical:
Not technical enough
Comments:
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);
}
Worth:
Worth reading
Technical:
Not technical enough
Comments:
how do i exactly apply the script to my code? do i place the java script on top thaen call it out at the image?? is there a sample i can view?