IE “Object doesn’t support this action”

I ran into this little bundle of awesome while trying to work with JSON and jQuery. In FireFox (as always) everything worked wonderfully. But as soon as I opened it up in IE it quickly turned into anything Microsoft is involved in, a huge cluster.

After hunting and hunting I found the issue with this bit of javascript:

for(item in ResultsArray.items){….

Turns out in IE ‘item’ is a reserved word. So watch out for that.

Ugg I hate IE. I hate how it makes me scream and complain.

Damn you MS!

Thanks for the pointer from Johannes Fahrenkrug’s site.

Update: this little bit comes from Bill in the comments. Makes a world of difference and no, I hadn’t tried this. =)

for (var item in ResultsArray.items) {….

Note the ‘var’ statement.

The reason I ask is that I use the variable ‘item’ all over in my IE code and never have a problem *unless* I forget to ‘var’ a local variable named ‘item’.

Thanks, Bill.