PDA

View Full Version : javascript window positioning



shuga
August 1st, 2003, 11:59 AM
I've written this function and I would like to change the top and left values to variables so that the window will appear 100 px from the top right of the screen not the top left

so i just need to figure out how to detect the horizontal screen resolution and then position the window 100 px + the pop up window width away from that number

here's the script i have so far



<!-- begin pop up window function -->
<SCRIPT LANGUAGE="Java-Script">
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,men ubar=0,resizable=0,width=300, top=100, left=100, height=400');");
}
</script>
<!-- end pop up window function -->

DigitalPimp
August 1st, 2003, 12:06 PM
That doesn't make any sense to me. If you say left=100 then it will position it 100 from the left most position... You don't have to detect resolutions because it does it automatically for you.

P.S. that script isn't very good. You don't need most of that code.



function popUp(url) {
window.open(url, 'newWin', 'toolbar=0,scrollbars=0,location=0,statusbar=0,men ubar=0,resizable=0,width=300, top=100, left=100, height=400');
}

shuga
August 1st, 2003, 12:11 PM
yes, i'm a newb when it comes to javascript

i think you misunderstood what i want. i want it 100 pixels from the right of the screen that's why i wanted the screen.width

shuga
August 1st, 2003, 12:13 PM
i got it to work



function popUp(url) {
rightPos=screen.width-400;
window.open(url, 'newWin', 'toolbar=0,scrollbars=0,location=0,statusbar=0,men ubar=0,resizable=0,width=300, top=100, left='+rightPos+', height=400');
}


thanks for the help

DigitalPimp
August 1st, 2003, 12:19 PM
oh I read the message wrong, my bad. I was thinking you should only need to do this if you want position from the right. dur dur dur.. ;)