Click to See Complete Forum and Search --> : Set window size on open?


Bigjohn
12-05-2003, 04:25 PM
Can i set the size of the window when the site opens? Say someone navigates to 'www.mysite.com'... is there a way to, in the index.html page, size the window to be max-client or 800x600 whichever is bigger?

and speaking of window size, is this the browsers full size we're talking about or the viewable page size? (viewport?)

THanks!

John

David Harrison
12-05-2003, 05:08 PM
To resize a window onload you can do this:

<body onload="window.resizeTo(800,600);">

But to resize to the biggest value, you'll have to run a function:

<script type="text/javascript"><!--

function doresize(){

w=screen.availWidth;
h=screen.availHeight;

w=(w<800)?800:w;
h=(h<600)?600:h;

window.resizeTo(w,h);}

//--></script>

</head>

<body onload="doresize();">

Bigjohn
12-05-2003, 08:11 PM
Ok, what I'm trying to do is open a page that is the same size as the site I've done with CSS.

The 'height' values of my 3 sections add up to 600, the width values are 800.

I use your script and it's smaller than the 'CSS' defined page and so it has scroll bars.

How do I fix that? When i do the resize function is that defining the actual viewport size or the size of the browser as defined by outer edges?

John

David Harrison
12-06-2003, 07:32 AM
The resizeTo will resize the outer edges of the browser window, this means that you'll have to play around with it a bit to get the right size for the actual content window. Sorry.

Bigjohn
12-06-2003, 07:46 AM
Thanks - and by the way, the wife LOVES your signature! Don't understand why, but she says it fits me exactly!

Is there a property that allows you to resize to a defined viewport size?

John

David Harrison
12-06-2003, 12:29 PM
I don't know of one for a main browser window, but if you were to open a pop-up, the values that you give for the size of the window will in fact be used for the inner width and height.
Maybe you should open a pop-up when someone visits your site. However make sure that there is still a viewable page there for people without JavaScript and those with pop-up's disabled.