spacer

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

home / experts / javascript / column19


Resizing the Page

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

In Navigator 4.0x, a dynamic content layout is lost when the user resizes the browser window. In order to restore the layout of the page, we must reload the page when a resize event occurs:

if (NS4) onresize = redo;

function redo() {
  location.reload();
}

We set the onresize event handler to redo, so the redo() function is invoked when the window is resized. It, in turn, reloads the page by calling the built-in location.reload() method.

In Navigator 4.0x, a resize event occurs when the page loads, immediately after the load event. So when the redo() function reloads the page, the onresize event handler is triggered again, causing an endless loop. As a matter of fact, the loop starts when the page is first loaded, because the "side-effect" resize event occurs when the page loads.

The workaround is just as simple. We need to set the onresize event handler after the page loads, so the "side-effect" resize event doesn't trigger it. We'll use the well-known setTimeout() function to achieve our goal:

if (NS4) onload = init;

function init() {
  setTimeout("onresize = redo", 1000);
}

function redo() {
  location.reload();
}

The Dynamic HTML Lab has more information on the onload/onresize bug.

http://www.internet.com

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint


Created: May 21, 1998
Revised: May 21, 1998

URL: http://www.webreference.com/js/column19/resize.html