Saturday, April 08, 2006

Browser interoperability

I've had a lot of headaches with this. In general my approach is to use and libraries/ open source functions etc that are out there since they will almost certainly work better in a cross browser environemnt than what I throw together

This doesn't always work out however and I find myself writting css pages, javascript etc...

Anyway the problem. Looks like a bug in IE. It appears that the document.getElementById() function does not work... However on further examination it turns out that the ID attribute must be the first (or before most atribute) attribute in an html element.

For example

<img class="myimg" name="myimg" src="myimg.jpg" id="12"/>

If you then try to access this in javascript it doesn't work

docuemnt.getElementById("12") returns a null.

However if you re-jig the element so id is the first attribute then it works fine.. Bizarre.

<img id="12" class="myimg" name="myimg" src="myimg.jpg" />

[tested on IE 6.02]