Last post Nov 28, 2006 11:23 AM by eappell
Nov 27, 2006 06:11 PM|eappell|LINK
This is technically a browser issue, not an asp.net issue, but I wasn't sure where else to post this...
This is a weird behavior that I've noticed only happens in IE7... If I have a dropdown that uses onfocus to change the style of the dropdown in some way, the user must click twice on the dropdown to expand it. It appears that the first click executes the
onfocus code, but does not expand the dropdown. It's annoying, and I'm not sure if there's a workaround. I have searched high and low and haven't found this mentioned anywhere else, but I have reproduced it using simple examples and it's a consistent behavior.
Here is my example:
<select onblur="this.style.backgroundColor='#ffffff'" onfocus="this.style.backgroundColor='#0000ff'">
<option>test text 1</option>
<option>test text 2</option>
<option>test text 3</option>
<option>test text 4</option>
run this code in IE7 and you'll see that you must click twice on the dropdown to get it to expand. Does anyone know of a workaround for this? It works as expected in every other browser I've tried it in, just not in IE7.
Nov 27, 2006 08:26 PM|koese|LINK
Add one more attribute in the select tag to resolve the IE7 problem i.e - 'onfocusin'
Nov 27, 2006 11:03 PM|eappell|LINK
AWESOME! Worked like a charm. Why did I not find that mentioned anywhere else...?? Is it documented somewhere?
Thanks for the answer!
Nov 27, 2006 11:23 PM|koese|LINK
Thanks for your feedback,
It’s weird but true, it only works With Microsoft Internet Explorer 5.5 and later
Nov 28, 2006 04:28 AM|LudovicoVan|LINK
Does anyone know of a workaround for this?
A blind guess, since I have yet to see IE7, but you might try returning
true from your handler, so that the event (maybe) gets furtherly processed:
onfocus="this.style.backgroundColor='#0000ff'; return true"
Anyway, this is really weird, given that IE7 was said to be much better in regards to standards conformance... :(
Nov 28, 2006 11:23 AM|eappell|LINK
I agree, it's weird, but not the only UI fix I've had to apply to my websites since IE7 came out... Anyways, the onfocusin fix worked fine, and adding return true did not, but thanks for the suggestion! Looks like onfocusin is the key here.