zoukankan      html  css  js  c++  java
  • 最全,最准确的js判断终端类别(chrome,ie,edge,safari,firefox,opera,Blink)

         let isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
    
    // Firefox 1.0+
            let isFirefox = typeof InstallTrigger !== 'undefined';
    
    // Safari 3.0+ "[object HTMLElementConstructor]"
            let isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || (typeof safari !== 'undefined' && safari.pushNotification));
    
    // Internet Explorer 6-11
            let isIE = /*@cc_on!@*/false || !!document.documentMode;
    
    // Edge 20+
            let isEdge = !isIE && !!window.StyleMedia;
    
    // Chrome 1 - 79
            let isChrome = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime);
    
    // Edge (based on chromium) detection
            let isEdgeChromium = isChrome && (navigator.userAgent.indexOf("Edg") != -1);
    
    // Blink engine detection
            let isBlink = (isChrome || isOpera) && !!window.CSS;
    
    
            let output = 'Detecting browsers by ducktyping:<hr>';
            output += 'isFirefox: ' + isFirefox + '<br>';
            output += 'isChrome: ' + isChrome + '<br>';
            output += 'isSafari: ' + isSafari + '<br>';
            output += 'isOpera: ' + isOpera + '<br>';
            output += 'isIE: ' + isIE + '<br>';
            output += 'isEdge: ' + isEdge + '<br>';
            output += 'isEdgeChromium: ' + isEdgeChromium + '<br>';
            output += 'isBlink: ' + isBlink + '<br>';
            document.body.innerHTML = output;
    执着于各种技术的代码小白
  • 相关阅读:
    get请求中文乱码及get,post编码探究
    spring使用redis做缓存
    tomcat中session在两个webapp中实现共享
    JDK8 HashMap 源码解析
    Windows Apache服务器配置
    怎么使用IDEA
    面试中的Java链表
    设计模式解密(12)- 桥接模式
    Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    设计模式解密(11)- 命令模式
  • 原文地址:https://www.cnblogs.com/rimoZhou/p/13749418.html
Copyright © 2011-2022 走看看