[thelist] Crossbrowser options.add() method

Peter-Paul Koch pp.koch at gmail.com
Wed Dec 7 03:01:30 CST 2005

> > Safari 1.3 does not play well with options.add() method.  Any pointers to  a
> > cross browser replacement for options.add() that supports positional insert?
> >
> > Thanks!
> >
> What's wrong with DOM's createElement and appendChild methods?
> These are the most cross-browser, future-proof and standard way of
> appending nodes as far as I know.

They are stronly counter-indicated for creating options, since
Explorer may crash on it, or at least give no end of trouble. The
add() method is totally useless, too, since the second argument must
be an options object in Moz and must be a number in Explorer.

Therefore in the specific case of options I recommend using the Level 0 DOM way:

select.options[select.options.length] = new Option ('text','value');

ppk, freelance web developer

More information about the thelist mailing list