spacer

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

home / experts / javascript / column33


Further Streamlining of the HTML Scroller Code

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

The implementations of the HTML Scroller differ quite a lot between Netscape Navigator and Internet Explorer. The main one is that we implemented the DHTML element with the layer object in Netscape Navigator, and with the in-line frame, <IFRAME> tag, in Internet Explorer. Therefore, the flow in Netscape Navigator is cleaner and simpler. It is all confined to the same scroller script. The flow in Internet Explorer is more complex, as we described in our previous column. The external HTML file includes a small JavaScript piece that is responsible to call the main script.

We have made every effort to remove any browser dependency from the scroller script. These browsers differ, for example, in their support of the onload event for DHTML elements. Internet Explorer does not support it, while Netscape Navigator does. The onElementLoad() function expects three parameters: the element id, the action required, and the parameters needed for this action:

function onElementLoad(element, doThat, theseParameters) {
  if (NS4) eval(element).onLoad = eval(doThat)
  else eval(doThat + theseParameters);
}

As you can see, in Netscape Navigator we translate the function call to an onLoad event handler initialization. In Internet Explorer, we just call the action without any event handling stuff. Here is how the calls to this function look like:

onElementLoad(secondPage, "launchScroller", "()");
onElementLoad(firstPage, "makeSecondPage", "()");

Using such functions helps streamlining the main script, as all browser dependencies are handled in these functions instead of the main script. Another potential streamlining is the conversion of Netscape Navigator's DHTML model to the in-line <ILAYER> tag, which is very similar to the Internet Explorer's <IFRAME> tag. We opted not to do it, as the <ILAYER> tag is notoriously buggy.

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

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: January 4, 1999
Revised: January 4, 1999

URL: http://www.webreference.com/js/column33/streamline.html