Is it possible to set the size attribute of a select element using JavaScript in Internet Explorer 11?

Viewed 1953

I have a page with following HTML

<select id="person" size="5" onchange="document.getElementById('person').size = 1;">
    <option value="Homer">Homer</option>
    <option value="Marge">Marge</option>
    <option value="Bart">Bart</option>
    <option value="Lisa">Lisa</option>
    <option value="Maggie">Maggie</option>
</select>

When you select an item in the list, the list's size is set to 1 (so it renders as a combo box rather than a list box).

When using Internet Explorer 11, the browser crashes. When testing with other browsers there is no problem. I have tried the following browsers:

  • Firefox 25.0.1
  • Chrome 31.0.1650.63 m
  • Internet Explorer 10

There is a jsfiddle here http://jsfiddle.net/pC9zL/11/ containing the above HTML.

Has anyone else experienced this problem and if so are they aware of any possible solutions?

2 Answers
Related