Intrepid Blog

Stupid IE (2)

To create a multiple select-box with javascript you need a very ugly hack in IE.

if (navigator.appName.match(/Internet Explorer/)) {
	fsel = document.createElement(\'<SELECT MULTIPLE>\');
} else {
	fsel = document.createElement(\'select\');
	fsel.multiple = true;
}

2 comments

Preserved from the WordPress version of this blog. Commenting is closed.

Bas

Of course you could also try the less ugly hack using IE’s conditional comments. It may require you to write IE code in a separate file, though.

Bas Westerbaan

It’s not the browser check that I find ugly — it’s the ‘<SELECT MULTIPLE>’ that is so utterly wrong.