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, 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.
PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
Update:
Just an interesting note to add.
The tagName property of a node still returns uppercase. 0 comments