onclick event in select HTML not working in Safari

后端 未结 4 889
半阙折子戏
半阙折子戏 2021-01-15 20:19

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.

相关标签:
4条回答
  • 2021-01-15 20:29

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

    0 讨论(0)
  • 2021-01-15 20:33

    <select onclick="changeDate()">

    Should be changed to

    <select onchange="changeDate()">
    

    Safari seems to react as a open even and not a close event, like in the other browsers.

    0 讨论(0)
  • 2021-01-15 20:53

    For me in Chrome, onclick working with second click on select box Where as in FF & IE, its working fine for first click itself.

    0 讨论(0)
  • 2021-01-15 20:54

    Sometimes you need to add preference to the JavaScript function as "javascript:"; for example:

    <select onclick="changeDate()">
    

    should be

    <select onclick="javascript:changeDate()">
    
    0 讨论(0)
提交回复
热议问题