简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM