spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / dhtml / diner / resize
DHTML Diner Logo

This is a Netscape Navigator 4 technique. The in-page examples will only work in Navigator 4 versions with the bug (ex. v4.04).

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

Ensuring DHTML Layout on Resize (4)

As stated on the first page, to ensure DHTML layout, we must reload the page. Our short script then looks like this:

origWidth = innerWidth;
origHeight = innerHeight;
function reDo() {
   if (innerWidth != origWidth || innerHeight != origHeight) 
      location.reload();
}

onresize = reDo;

Reload for Navigator 4 Only

In a cross-browser script, we would make the above code available only to Navigator 4. See Browser Variables, in DHTML Diner, for a discussion of our preferred browser detection variables. The final script would be:

<SCRIPT LANGUAGE="JavaScript1.2">
<!--
   NS4 = document.layers;
   if (NS4) {
      origWidth = innerWidth;
      origHeight = innerHeight;
   }

function reDo() {
   if (innerWidth != origWidth || innerHeight != origHeight) 
      location.reload();
}

if (NS4) onresize = reDo;
//-->
</SCRIPT>

Notice that we do not need to re-declare origWidth/origHeight, since we reload the page! We would need them, however, if the statements executed kept us in the same page.

Bugless Versions

Versions of Navigator 4 without the bug are not affected by our script. Versions with the bug have the bug fixed. It is therefore prudent to include the script in all your DHTML pages.

For One-Line Freaks Only

Since we highly recommended that the above script be included in ALL DHTML pages, we have shortened it to a one-line version, which we will not elaborate on, but advanced scripters should be able to follow the logic. For the rest of you, a cut and paste will suffice:

if(document.layers){origWidth=innerWidth;origHeight=innerHeight;onresize=function(){if(innerWidth!=origWidth||innerHeight!=origHeight)location.reload()}}


Produced by Peter Belesis and

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business

All Rights Reserved. Legal Notices.
Created: May 07, 1998
Revised: Oct 07, 1998

URL: http://www.webreference.com/dhtml/diner/resize/resize4.html