|
Creating DHTML Web pages for Navigator 4.x and IE 4.x is, frankly, and royal
pain! The two browser implementations of the Document Object Model (DOM) are
so diffenerent that creating DHTML pages that follow the published standards
often doesn't work. The result - chaos and confusion for the web coder!
The only way to solve many of the Navigator vs. IE 'issues' with research
and trial-and-error.
Well, I've lived the browser 'issues' every working day for almost 3 months,
and figured out a lifetime's worth of CSSP and JavaScript workarounds for
DHTML web pages on Navigator and IE, so here are a few of my tips and
Tricks .... watch this space, I'll be adding more when I have time!
The Document Object Model (DOM)
So much has been written about the DOM, and the differences between
IE and Navigator that me talking about the DOM would be pointless!
But for DHTML web pages, the long-and-the-short of the DOM is this:
IE refers allows you to refer to HTML elements using the all
object, while Navigator uses the layers
object. While this
can be extremely confusing, it also allows you to write portable
DHTML JavaScript very easily:
// is this Navigator?
if (document.layers) {
// Navigator specific code here ...
}
// is this IE?
else if (document.all) {
// IE specific code here ...
}
DIVs, LAYERs, SPANs and ILAYERs
Combining of CSSP and JavaScript, i.e. DHTML, gives the web coder the ability
to creating awesome interactive web sites. DIVs, LAYERs, SPANs and ILAYERs
are probably the most used HTML tags for a DHTML web site. CSSP allows for
detailed styles and formatting of the HTML, while JavaScript is the 'glue'
that binds it all together into DHTML. Here are some of the things I've
discovered about DHTML, ranging from the obvious to the arcane.
<DIV><LAYER>
... html tags here ...
</LAYER></DIV>
<DIV ID="myDiv">some html</DIV>
document.myDiv.style.border-width = "5px";
style
property, second, Navigator refers
to CSSP elements (like DIV) by NAME, and third, Navigator doesn't
allow you to manipulate a DIV with JavaScript unless it's position
has been set to 'absolute'. So, for IE and Navigator, the example becomes:
<DIV ID="myDiv" NAME="myDiv" STYLE="position:absolute;">
some html
</DIV>
// is this Navigator?
if (document.layers) {
document.layers["myDiv"].border-width = "5px";
}
document.myDiv.border-width = "5px";
else if (document.all) {
// IE specific code here ...
}
Style Sheet attributes
I've only got one style sheet tip for now ....
background-color
bgColor
background-color
. Enough said.
<[email protected]>
in the code.