Forum Moderators: open
Unfortunately, the destination position of a Javascript moveTo is defined from the top left and no other way. But you can add JS to retrieve the screen size, and then calculate what the margin would be from the top left instead of the top right.
There are several related JS variables about whose vintage I do not venture a guess:
screen.width and screen.height-- simply the width and height of the screen in pixels
screen.availWidth and screen.availHeight-- width/height of the screen in pixels minus "fixtures" like the Windows or MS Office taskbars
Borrowing then from [rtfm.atrax.co.uk...] (I'm actually rather far from a JS expert-- we try not to use it)
<script type="text/javascript">
function start() {
// retrieve user's available screen resolution
w = window.screen.availWidth;
h = window.screen.availHeight;
// resize window according to space available, up to 750x350 if possible
resizedW = (w >= 750)? 750 : w;
resizedH = (h >= 350)? 350 : h;
window.resizeTo(resizedW,resizedH);
// to align the window to the right, subtract its
// width from the available space to find the x value of
// the left margin; set y to zero for top
var x = (w - resizedW);
var y = 0;
window.moveTo(x,y);
}
</script>
<body onLoad="start();">
[edited by: tedster at 7:45 pm (utc) on April 20, 2004]
[edit reason] make link active [/edit]
Usually you want to open up a second, popup style window when you want a custom sized window, that doesn't create that problem, since the original opener window remains the standard size.
Is there a line (or 50) that I could add to reset the saved settings so that it only does this once, instead of from then on? Thanks for the help.
<body onunload="window.resizeTo(w,h);window.moveTo(0,0);">
this would at least sometimes return the browser to the settings you got from the screen measurements, although whether this would happen fast enough on window closing to get into the window registry is something you'd have to test.