Thursday, April 02, 2009

IE8 Change causes Form Element References to break

I had a problem with some web pages on a particular application after upgrading to IE 8. Referencing forms like this stopped working (but continued to work in Firefox).

document.forms[0].field_name
document.forms["formname"].field_name

After exploring what I thought was an IE 8 bug further I found that my HTML code was missing a "td" tag in one place. Apparently because the HTML code was not well-formed somehow that affected the JavaScript code and was not executed properly.

Most of my HTML code is well-formed due to use of my web publishing engine (BMetrix.com) which forces a certain level of compliance but this was a custom component designed outside of the system which ended up having this particular issue.