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;
    执着于各种技术的代码小白
  • 相关阅读:
    Maven报错,没有有效的生命周期
    6张图解释IO流
    传统Java JDBC
    快速杀死占用8080端口进程的批处理(kill-8080.bat)
    ubuntu环境配置终极解答
    Linux系统下Java开发环境的配置(未完...)
    Linux常用命令及操作(第二弹)
    Linux下安装Mysql
    Linux常用命令及操作
    int转LPCTSTR
  • 原文地址:https://www.cnblogs.com/rimoZhou/p/13749418.html
Copyright © 2011-2022 走看看