MCPcopy Create free account
hub / github.com/hoothin/UserScripts / eventSupported

Function eventSupported

Picviewer CE+/dist.user.js:13654–13671  ·  view source on GitHub ↗
( eventName,elem )

Source from the content-addressed store, hash-verified

13652
13653 //事件支持检测.
13654 function eventSupported( eventName,elem ){
13655 elem = elem || document.createElement("div");
13656 eventName = "on" + eventName;
13657 var isSupported = (eventName in elem);
13658 if (!isSupported){
13659 if(!elem.setAttribute){//setAttribute是元素节点的方法
13660 elem=document.createElement("div");
13661 };
13662 var setAttr;
13663 if(!elem.hasAttribute(eventName)){
13664 setAttr=true;
13665 elem.setAttribute(eventName, "return;");
13666 };
13667 isSupported = typeof elem[eventName] == "function";
13668 if(setAttr)elem.removeAttribute(eventName);
13669 }
13670 return isSupported;
13671 }
13672
13673
13674 //检测属性支持.dom属性

Callers 2

getSupportEventNameFunction · 0.70
getSupportedFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected