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;
    执着于各种技术的代码小白
  • 相关阅读:
    BZOJ3197:[SDOI2013]刺客信条——题解
    C 程序与 C++ 程序之间的相互调用
    使用Dev C++调试(debug)程序
    ARM 汇编指令 ADR 与 LDR 使用
    华为交换机以 LACP 模式实现链路聚合
    DLCI 简介
    华为路由器帧中继 FR 实验
    GVRP 的工作机制和工作模式
    华为路由器 HDLC 实验
    华为路由器 IPSec 与 GRE 结合实验
  • 原文地址:https://www.cnblogs.com/rimoZhou/p/13749418.html
Copyright © 2011-2022 走看看