Search code examples
javascriptsafaridom-events

onclick event in select HTML not working in Safari


I have an ASP.NET dropdown list control with onclick and onchange JavaScript events. Both work in IE, Mozilla, Opera and Chrome, but not in Safari. When I remove the onclick event, onchange suddenly works.

The reason I use onclick is to get the value of the dropdown list before it changes. Is there a way I can do that without using onclick? That is, get the value of the dropdown list before it changes/a new value is selected? I want to do this in JavaScript only.


Solution

  • Replacing the onclick event with onfocus solved the problem. I guess Safari doesn't like onclick event on select elements.