[thelist] Centering / positioning a popup
Anthony Baratta
Anthony at Baratta.com
Sun Oct 6 10:54:01 CDT 2002
At 08:34 AM 10/6/2002, fstorr wrote:
>How can I position a pop up window up against the right hand margin of
>the screen? I've seen examples where you can position a window, say
>10px from the top and 50px from the left, but I need one to be tight
>against the right hand edge.
>
>Secondly, the same question, but with the pop up centered.
You need to grab the screen size and massage from there. Here is a JS
script I use to Center, should be easily modifiable for your other needs.
openCtrWindow('/foo.html','_Print','600','400','scrollbars=1,toolbar=1');
function openCtrWindow(theURL,winName,winWidth,winHeight,otherFeatures) {
var x = 0;
var y = 0;
x = (screen.availWidth - 12 - winWidth) / 2;
y = (screen.availHeight - 48 - winHeight) / 2;
if (otherFeatures != "") {otherFeatures = "," + otherFeatures}
var features = "screenX=" + x + ",screenY=" + y + ",width=" + winWidth
+ ",height=" + winHeight+",top="+y+",left="+x+"'"
+ otherFeatures;
var popWindow = window.open(theURL,winName,features);
popWindow.focus();
}
---
Anthony Baratta
President
Keyboard Jockeys
"Conformity is the refuge of the unimaginative."
More information about the thelist
mailing list