PDA

View Full Version : Window positioning on exit



serendipity
08-25-2005, 02:40 AM
Hi,

I've got this piece of code below:

function leave() {
window.open('../newindowonexit.html','','toolbar=no,menubar=no,location=no,height=440,width=330');
}

what do I add to to open the new window in exactly the position I want it to open? say right in the middle of the page etc. I know its has something to do with x and y coordinates but I dunno how to put it into code.

thanks for any replies!

jscheuer1
08-25-2005, 06:27 AM
function leave() {
window.open('../newindowonexit.html','','toolbar=no,menubar=no,location=no,top=100,left=300,height=440,width=330');
}Top and left are the number of pixels from the top and from the left that you wish the upper left corner of the new window to be.

Twey
08-25-2005, 10:00 AM
If you wanted it in the middle:

window.open('../newindowonexit.html','','toolbar=no,menubar=no,location=no,top=' + ((screen.height / 2) - 220) + ',left=' + ((screen.width / 2) - 165) + ',height=440,width=330');

serendipity
08-26-2005, 03:05 AM
Thanks for all the tips guys! I'll surely use both of them.

One thing, though...now, that I know, the simple stuff...what if I have different links opening different windows/pages that need several types of positioning and customisation?

jscheuer1
08-26-2005, 04:21 AM
Then you should check out Popup Window Generator (http://www.dynamicdrive.com/dynamicindex8/popwin.htm).