The following Javascript to resize a select list breaks in Google Chrome. It works when pasted into a field, but when you click on it, βAw, Snap!β Appears. error page.
<select onfocus="this.setAttribute('size', 3);">
<option>selectList with onfocus</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
Works well in FF and IE. This is some kind of conflict between onfocus (no problem if I implement it onClick) and setting the size attribute. I was told that it also breaks down in Safari.
Any help, ideas or workarounds are welcome.
(PS Yeh I know that this is not a very good form for resizing a pick list, but this is what the boss / client wants)
source
share