...

View Full Version : math variable not working



kevyBoy
07-02-2003, 09:54 PM
here's the function I call to pop up a window
and center in depending on the monitor resolution.

function doIt() {
var centerW=((screen.width - 800) / 2);
var centerH=((screen.height - 600) / 2);
window.open('main.htm','EgrArt', 'height=600,width=800,location=no,left=centerW,top=centerH,scrollbars=no,resizable=no,menubar=no');
}


centerW and centerH give the right numbers when I alert them, but they don't work within the window.open and I don't know why.

Any help would be greatly appreciated

beetle
07-02-2003, 10:19 PM
You have to break from the string and concatenate so that their values are used

window.open('main.htm','EgrArt', 'height=600,width=800,left=' + centerW + ',top=' + centerH );

Also, so you know, any window property defaults to false, so you don't need to set all of them to 0. Just leave them out and they won't show up.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum