Javascript window positioning

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,menubar=0,resizable=0,width=300, top=100, left=100, height=400');");
}
</script>
<!-- end pop up window function -->

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,menubar=0,resizable=0,width=300, top=100, left=100, height=400');
}

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

i got it to work


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

thanks for the help

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… :wink: