zoukankan      html  css  js  c++  java
  • 史上最强大的浏览器嗅探

      在前端开发中经常会遇到一系列兼容性问题,怎样精准地识别出各个浏览器的版本是一件很头痛的问题,尤其是navigator有可能被厂商伪造的情况。虽然大神们建议要针对浏览器特性来处理而不是通过浏览器版本,但是实际操作过程中却有相当大的困难。

      以下是大神们总结的各种浏览器嗅探的办法,亲测无误

    IE篇:

    ie=!!window.VBArray
    ie678=!+"v1"; ie678=!-[1,]; ie678='v'=='v'; ie678=('a-b'.split(/(~)/))[1]=="b" ie678=0.9.toFixed(0)=="0" ie678=/w/.test('u0130') ie8=window.toStaticHTML ie9=window.msPerformance ie678=0//@cc_on+1; ie67=!"1"[0] ie8=!!window.XDomainRequest; ie9=document.documentMode&&document.documentMode===9; ie10 = window.navigator.msPointerEnabled; ie11 = !!window.MSInputMethodContext;

    Firefox篇:

    firefox=!!window.netscape;
    firefox=!!window.updateCommands;
    safari=window.openDatabase&&!window.chrome;
    chrome=!!(window.chrome&&window.google);

    移动设备篇:

    iphone=/iphone/i.test(navigator.userAgent);
    iphone4=window.devicePixelRatio>=2;
    ipad=/iPad/i.test(navigator.userAgent);
    android=/android/i.test(navigator.userAgent);
    IOS=iphone||ipad;
  • 相关阅读:
    Ubuntu下基于Virtualenv构建Python开发环境
    Linux查看用户登录信息-last
    SpringCloud实践引入注册中心+配置中心
    git仓库构建小记
    windows下使用hbase/opencv/ffmpeg小记
    Java执行jar总结
    命名空间
    phpstudy ——composer使用
    template-web.js
    redis
  • 原文地址:https://www.cnblogs.com/lingtong/p/4156807.html
Copyright © 2011-2022 走看看