Tag: bugs


An Interesting IE6 Bug (bleurgh)

I came across an interesting bug in IE6 the other day, and couldn’t find any documentation of it on the internet, so thought I’d share it with you all here (aren’t you lucky?).

I was working on a distributable widget, which has the functionality to grab some embed code so you can place it with pride on your own website. This embed code was generated dynamically by JavaScript based on some parameters the user entered, and was then placed in a textfield using the jQuery $().val(value) function. This worked fine in most browsers, but IE6 would throw a wobbly at this point in the form of an “Unspecified Error”. Incredibly helpful.

I found that the bug didn’t occur if I escape()‘d the value before I passed it into the textfield. It seems, therefore, that IE6 has an issue with strings that contain HTML content – presumably it was trying to parse the HTML when it was put in the textfield. The same behaviour was observed when using document.getElementById(…).innerHTML = value; as well.

The solution was to use the jQuery function $().text() – and this works cross browser. Presumably this only works for textfields – if you are setting the contents of normal text inputs then I’m not quite sure what you will observe. But then, you never are with IE6…