View Full Version : Got the Shakes on Browser Window Maximize?

08-04-2002, 09:25 PM
I used the dynamic drive script below in each page of a site to maximize the browser window on load, but I notice it creates a shake as I move from page to page within the site (the window is already maximized, and I guess each time the maximize function is triggered moving from one page to the next the attempt to maximize causes the 'shake'). If I only maiximize the main page, will all the other pages maximize anyway? Is there a way to accurately determine if the browser is already maximized and not re-maximize it?


<script language="JavaScript1.2">

Auto Maximize Window Script- By Nick Lowe (nicklowe@ukonline.co.uk)
For full source code, 100's more free DHTML scripts, and Terms Of Use
Visit http://www.dynamicdrive.com

if (document.all) {
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;

Graeme Hackston
08-04-2002, 09:41 PM
It doesnít actually maximize the browser, it sizes it by using the screen size.

I think once it has been resized it will stay that way until the user changes it. It will help if you put it on your index page only but they could enter your site by another page.

I think you need a method of passing a variable between pages. Maybe cookies or a hidden frame?

08-04-2002, 11:22 PM
you need a method of passing a variable between pages. Maybe cookies or a hidden frame?


I would rather simplify than complicate - cookies or frames are overkill I think for what I am trying to manage. I wonder if I can inspect the settings that the script alters at the top of the script and then bypass the script logic if the settings indicate the window is already max. Is it possible to detect if the window is at 0,0 and width and height are equal to available width and height?


Graeme Hackston
08-04-2002, 11:33 PM
Yes that's a better idea.

I've never done anything with screen position but it sounds like it would work

Something like:

if ((screen x ==0) && (screen y ==0)) {
} else { // do nothing

08-05-2002, 01:20 AM
Thanks... I've tended to want to maximize because I have large images in the pages and want them to be fully visible. But the more I think about it, the more I think the browser should be left as the viewer has sized his/her other windows. Especially since I am introducing that shake thing every time I resize it.


Graeme Hackston
08-05-2002, 01:33 AM
How about going in the opposite direction. You could size the images to fit the available window.

08-05-2002, 03:27 AM

Thanks for the suggestion. I currently already load one of three different sized images based on screen resolution, for 640, 800 and 1024 widths. This gives me 3 standard sizes that cover most viewers. I found that resizing images (i.e. by way of the width and height attributes of the image tag) caused some subtle problems in the image presentation that I won't bore you with here. Letting the size flow against the available window means you may have the image at an absurdly small size, and means that you have much less ability to shape the way the text and other elements fall around the image, and also means that you must either adjust if the viewer then resizes or leave the image inappropriately sized. If the viewer chooses to keep his browser window small, then he will see all web sites in the same limited manner, and so mine will be consistent with that. Why should I dictate how his browser is to be sized? If he sizes the browser for optimium viewing of most sites, then he will also see mine optimally. At least that was the conclusion I reached.


Graeme Hackston
08-05-2002, 08:19 PM
I haven't done this yet but I don't see why it wouldn't work.

If window sizes are used then the dimensions are written to the page, you could write an if else statement and use defined sizes when the window is at the extremes.

Iím only thinking in the context of stand alone images. I have no need for text flow but it might correct that also.