Javascript gripe # 2

The add() function of the html select object functions totally different in IE and Firefox.

It is defined as :
selectObject.add(option,before)

Where option is an option object. Before is the tricky part.

In firefox, the second parameter is supposed to be a reference to the option object you want to place your new object in front of. In IE, it is the index to the object you want to remove.

These are fundamentally different.

In FF, you have to do this:
boxRef.add(newOpt,boxRef.options[i]);

in IE, you do this:
boxRef.add(newOpt,i);

Apparently, Firefox is correct according to the DOM specifications:
void add(in HTMLElement element, in HTMLElement before) raises(DOMException);
void remove(in long index);

But tell me, why does the add method use an object while the remove uses an index???. The standard is messed up, not IE.

Anyway…

Leave a Reply