Thursday, March 23, 2006
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.
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, elem.style.left = foo; gets replaced with
elem.style.left = 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.