PDA

View Full Version : Pop up windows - centered to browser


Anna
03-12-2003, 02:35 PM
Does anybody know how to open a pop up window centered to the browser (not screen) from a page of a frameset?
I've found a script, using window.document.body.offsetWidth e window.document.body.offsetheight, but obviously the pop up window is centered with the document (not the frameset)

Mr J
03-13-2003, 08:58 PM
var posX = (document.body.clientWidth - Width) / 2
var posY = (document.body.clientHeight - Height) / 2


Depending on your frame layout, if you had a two frame frameset of columns where the left column was 200px and th eright frame was 400px

This would center in relation to the right frame

var posX = (document.body.clientWidth - Width) / 2

to center in relation to the frameset

var posX = (document.body.clientWidth - Width) / 2 -100



possibly?

Tommi
03-13-2003, 09:09 PM
Just a tiny information:

window sizes of the calling client... for...

Netscape/Mozilla:

wy= window.innerHeight;
wx = window.innerWidth;


IE:
wy= document.body.offsetHeight;
wx = document.body.offsetWidth;


------------------------------

popupwindow_x = ( wx / 2 ) - ( popupwindow_width / 2 );
popupwindow_y = ( wy / 2 ) - ( popupwindow_height / 2 );