JS Is there a way to check if an event exists?
I am trying to detect if a certain webkit event ' webkitAnimationEnd
' is supported by the browser, to do so I like to check if the event exists. But I can't seem to figure out how. Does anyone have a clue?
在没有浏览器嗅探的情况下检测事件支持表明这应该起作用:
'onWebkitAnimationEnd' in document.createElement('div');
What do you mean by "is supported"? Assuming you mean "Will be fired by the browser under a particular set of circumstances", then you need to simply recreate those circumstances (via script) and see if an event was fired; you can use a timeout handler to respond in the negative if the event was never handled.
Detect features by testing them, not by looking anywhere else.
链接地址: http://www.djcxy.com/p/59002.html上一篇: XMLHttpRequests上有可用的NavigationTiming接口吗?
下一篇: JS有没有办法检查一个事件是否存在?