spacer

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

home / experts / dhtml / column12
Developer News
Google Chrome Playing Catch-Up on Extensions
Open Solutions Alliance Gets New Leadership
Red Hat Spacewalk Expands Linux Management
Logo

Expandable Outlines
Cross-Browser: Initialization


A cross-browser version can be created without much ado, although several concessions will be made to the Navigator way of doing things. We must, for example, maintain the Navigator requirement of enclosing all outline heads, outline expandable elements, and subsequent elements in positioned elements (DIVs). We'll also keep the links to expandIt() as they are.

Contrastly, Explorer should not consider the DIVs as positioned elements, but as simple page divisions, and should use the display property toggle. Surprisingly, this is easily achieved.

First, we omit the inline STYLE attributes from the DIVs, and replace them with style CLASS identifiers:

We have assigned three types of classes: parent for the outline heads, child for the expandable elements, and regular for any DIV after the outline.

The DIVs will be considered positioned elements, only if the class style declarations include positioning properties. We must make sure that a different definitions exists for Navigator and Explorer.

Dynamic Stylesheets

Since a CSS stylesheet is just text enclosed in HTML tags, it can be created on-the-fly using JavaScript:

Now, Navigator has its positioned elements, and Explorer has simple HTML elements, some of which (members of the child class) have a display of none. For Explorer, the parent and regular classes do not exist and are overlooked.

With just a few lines of code, we have created two co-residing but conceptually completely different versions of the same page. The on-screen result is, of course, exactly the same.

Original Layout

Our end-of-page Navigator-specific snippet remains the same:

Explorer needs no pre-page-load instructions, as it has already rendered the outline correctly. It will, however, need a bit of additional initializtion immediately after the page loads, so our onload = initIt; handler remains for both browsers.

A little more creative combining and we will have our cross-browser version.


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: Jan. 14, 1998
Revised: Jan. 18, 1998

URL: http://www.webreference.com/dhtml/column12/outCROSSone.html