Thursday, March 23, 2006

XHTML goodness

Today, I was playing with a bit of DHTML with both Firefox and IE6.
At some point I added an XHTML doctype to make IE observe CSS a little better.
Suddenly, the script dies in Firefox.
error in parsing value for property 'left'. Declaration dropped.
This occures in the javascript that was reading and writing the left style property of an element.
The solution was multipronged.
First, everywhere I was setting the left style property, I needed to ensure that the number was followed with px.
Thus, = foo; gets replaced with = foo + "px";

Next, when finding elements by tag name, change to lower case.
var items = elem.getElementsByTagName("LI");
get replaced with
var items = elem.getElementsByTagName("li");

And finally, of course, ensure the document is valid XHMTL.

Googling found many people with this or a similar problem but, no solutions.

BTW, add the doctype header really made Firefox and IE6 treat CSS almost the same.
"-//W3C//DTD XHTML 1.1//EN"

Just an interesting note to add.
The tagName property of a node still returns uppercase.

Links to this post


Post a Comment

Subscribe to Post Comments [Atom]

<< Home

Links to this post on: