Add Syntax

This issue was fixed in Internet Explorer 8 beta 2.

I've been having a go at IE's CSS handling for quite a few pages now, but it is about time that I mentioned JavaScript - oops - JScript. That's what Microsoft call it in order to say; 'Yes, we know it is not standard'. But so many times, I have heard people complain about how other browsers handle JavaScript. Saying that their implementations are not correct, or are crippled.

Well here is pointing the finger at IE. At a classic. This is typical of the way that IE does things. Take standards, use some of the ideas, mix them with your own, and end up using the same words but making a different effect. The result? No-one is entirely sure which syntax the browser expects, so they try one, and fail, producing errors. Great. Similar to the way that IE mangles the attributes collection, but with that it is fairly easy to avoid errors.

You see, when adding a new option into a dropdown box, the add method is supposed to be passed a reference to the option it is to be placed beside. IE expects a numerical reference, not an object reference. If you pass the wrong thing to a browser, it will produce errors, and there is no way to know which should be used. The result, ugly browser detects, bad scripting, and incorrect accusations.

Demo: Click here to fill this dropdown box:

Workaround: Add options using
selectBox.options[index] = new Option('text','value')

Don't click this link unless you want to be banned from our site.