Click to See Complete Forum and Search --> : my window popup is always centered to the top left corner of the screen - why


suganya
09-18-2003, 02:12 PM
function popupAddlColumnDialog() {
var centerX=(screen.width-700)/2;
var centerY=(screen.height-700)/2;
document.getElementById('retrieveButton').focus();
document.advancedSearch.savedSearchName.value = parent.criteriaHeader.getSavedSearchName();
alert("savedSearchName in advancedSearch form = " + document.advancedSearch.savedSearchName.value);
window.open("","addColumnsWindow","width=700px,height=700px,top='+centerY+',left='+centerX+',scrollbars=yes,status=no,menubar=no,toolba r=no,resizable=no,center=yes,location=no");
parent.addColumnsSubmit.doOnClick();
}

the above code is the one i am using for centering my popup window...
i dont know what the problem is.....

it is centered to the topleft corner of the screen...why is this?...

thanks

gil davis
09-18-2003, 02:40 PM
it is centered to the topleft corner of the screen
The top left is the zero point of of the screen (top=0, left=0). If your screen resolution is 1024x768, then the center of the screen would be top=384, left=512. If you want the center of your 700x700 browser window to be located at the center of the screen, then that is what your code does, by making top=(768-700)/2=34 and left=(1024-700)/2=162.

What did you really want it to do?

suganya
09-18-2003, 02:53 PM
thanks for the reply...

my screen resolution is 1024x768....

i want my 700x700 window to be centered in the sense i want equal spaces on all 4 sides of this popup (equal spaces around teh window..)..(something like a modal dialog shows up when it opens...)

pyro
09-18-2003, 07:45 PM
Take a look at http://www.webdevfaqs.com/javascript.php#centeredpopup