参考文章:http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
事件特性检测:
1 标准浏览器,包括ie,判断指定的元素是否存在 “on” + event 属性.
2 在firefox 下,上述办法不适用,解决办法为:
创建div对象,给div元素添加指定的属性,属性名为 “on” + event,之后判断添加属性的类型,如果browser 支持添加的事件,type of 之后应该为 “function”.
1 | function isEventSupported(eventName, element) { |