首页 > 其他 > 详细

区分浏览器类型

时间:2017-07-18 21:27:24      阅读:282      评论:0      收藏:0      [点我收藏+]

How to detect Safari, Chrome, IE, Firefox and Opera browser?

Demo: https://jsfiddle.net/311aLtkz/

 1 // Opera 8.0+
 2 var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(‘ OPR/‘) >= 0;
 3 
 4 // Firefox 1.0+
 5 var isFirefox = typeof InstallTrigger !== ‘undefined‘;
 6 
 7 // Safari 3.0+ "[object HTMLElementConstructor]" 
 8 var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window[‘safari‘] || safari.pushNotification);
 9 
10 // Internet Explorer 6-11
11 var isIE = /*@cc_on!@*/false || !!document.documentMode;
12 
13 // Edge 20+
14 var isEdge = !isIE && !!window.StyleMedia;
15 
16 // Chrome 1+
17 var isChrome = !!window.chrome && !!window.chrome.webstore;
18 
19 // Blink engine detection
20 var isBlink = (isChrome || isOpera) && !!window.CSS;

 

区分浏览器类型

原文:http://www.cnblogs.com/hzj680539/p/7202759.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!