class BrowserDetector{
constructor(){
this.isIE_Gte6Lte10=/*@cc_on!@*/false;
this.isIE_Gte7Lte11=!!document.documentMode;
this.isEdge_Gte20=!!window.StyleMedia;
this.isFirefox_Gte1=typeof InstallTrigger!=="undefined";
this.isChrome_Gte1=!!window.chrome && !!window,chrome.webstore;
this.isSafari_Gte3Lte9_1=/constructor/i.test(window.Element);
this.isSafari_Gte7_1=
(({pushNotification={}}={})=>
pushNotification.toString()=='[object SafariRemoteNotification]'
)(window.safari);
}
isIE(){
return this.isIE_Gte6Lte10 || this.isIE_Gte7Lte11;
}
isEdge(){
return this.isEdge_Gte20 && !this.isIE();
}
isFirefox(){
return this.isFirefox_Gte1;
}
isChrome(){
return this.isChrome_Gte1;
}
isSafari(){
return this.isSafari_Gte3Lte9_1 || this.isSafari_Gte7_1;
}
}
//获取类的所有原型方法
let method=Object.getOwnPropertyNames(BrowserDetector.prototype);
method.forEach(name=>{
const prop=new BrowserDetector();//创建实例
if(name!=='constructor')//排除构造函数
{
if(prop[name]())
{
console.info(name);
}
}
})
11-05
621
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交