Click to See Complete Forum and Search --> : can you automatically center a pop up window?


phillkay
11-24-2003, 07:47 AM
Hello everyone.

I realise that the script for a pop-up window is very simple, but how do I program the window to automatically centre when the resolution varies from computer to computer? At the moment, pixel positions are stated, is there a way of making the pop up "centre" in the browser regardless of the resolution of the computer settings?

My site is www.syren.org.uk if you have any advice, I would be very grateful.

Cheers for now,

Phill Kay

gil davis
11-24-2003, 07:55 AM
var wid = 200;
var hgt = 200;
var tp = Math.floor((screen.height - hgt) / 2);
var lt = Math.floor((screen.width - wid) / 2);
window.open("","","top=" + tp + ",left=" + lt + ",width=" + wid + ",height=" + hgt);

phillkay
11-24-2003, 09:31 AM
Nice 1 geeza!!

csduk
12-01-2003, 10:03 AM
You may find this useful for customised pop up windows:

http://javascript.internet.com/generators/popup-window.html

Cheers.