Reason #6,182 to hate Internet Explorer

The other day I wanted to make a <select /> element a little easier for my users to select multiple options.  My plan was to capture the mousedown event on the <select />, grab the target <option />, select it and then cancel the event.  All was well until I got around to testing in IE.

Guess What?  It turns out that IE doesn't do diddly with <option /> elements.  The event argument on mousedown, click, mouseup, mouseover, and any other mousing motion on a <select /> will have a srcElement property equal to the <select /> and not the <option /> LIKE EVERY OTHER BROWSER ON THE PLANET.

As a last ditch effort, I even tried to grab the element under the mouse cursor by trying "document.elementFromPoint(e.clientX, e.clientY)".  When I checked the value in the debugger, there sat the same <select /> element as before just mocking me. That's all I have.  Time to move on to more important problems. 

In summary, damn you IE and your non-standard ways.

3 Comments so far

  1. NickV @ October 30th, 2009

    My condolences for your irritation.
    You can try using a jQuery plugin that replaces the select element and customize the plugin to add your mouse logic. The jQuery Dropdown Checklist might be a good candidate. I haven’t seen the code behind it, but it can’t be that bad.

  2. josh @ October 30th, 2009

    It was more of a quick “Hey, I can do this for my users” type of thing. I really wanted to use native widgets and it would have worked if IE wasn’t such a turd.

  3. Brandon @ October 30th, 2009

    I think the problem here may be that you tried to do something “nice for you users”.

Leave a reply