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;
  • 相关阅读:
    Java 中的定时任务(一)
    超实用 Git 使用方式介绍
    TCP 建立连接为什么要握 3 次手?
    OSI、TCP、IP、UDP 这些都是啥??
    Java 中线程安全问题
    PlantUML——3.Graphviz的安装
    PlantUML——2.中文乱码及解决
    PlantUML——1.Hello
    maven实战系列
    NGUI优化之Drawcall
  • 原文地址:https://www.cnblogs.com/lingtong/p/4156807.html
Copyright © 2011-2022 走看看