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
Google Chrome Playing Catch-Up on Extensions
Open Solutions Alliance Gets New Leadership
Red Hat Spacewalk Expands Linux Management

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.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

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

webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MS Access and MySQL · Cisco AutoQoS: VoIP QoS for Mere Mortals · While VoIP Adoption Explodes in Enterprise, Carrier Spending Lags

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

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