• 检测浏览器的特性


    1.检测桌面端浏览器的特性。

    $.checkDetect = function() {
            var Detect = {
                ie: /msies*d+.d/gi,
                chrome: /chrome/[w.]+(s)?/gi,
                firefox: /firefox/[w.]+(s)?/gi,
            };

            var ua = navigator.userAgent.toLowerCase(),
                info = {},
                match = [];

            for (i in Detect) {
                match = ua.match(Detect[i]);
                if (match) {
                    info.browser = i;
                    info.version = match.join(" ").match(/[0-9]+/g).join(".");
                }
            }
            return info;
        }

     检测移动端浏览器属性:

     checkDetect = function(){
                var Detect = {
                    webkit: /(AppleWebKit)[ /]([w.]+)/,
                    ipad: /(ipad).+soss([d+\_]+)/i,
                    windows: /(windowsd*)snts([d+.]+)/i,
                    iphone: /(iphone)soss([d+\_]+)/i,
                    ipod: /(ipod).+soss([d+\_]+)/i,
                    android: /(android)s([d+.]+)/i
                };

                var ua = window.navigator.userAgent,
                    browser = Detect.webkit.exec(ua),
                    ios = /((iPhone|iPad|iPod)/i.test(ua),
                    //["iPhone OS 5_1", "iPhone", "5_1"]
                    tmp = [],
                    N = {},
                    match = [];
                    for(i in Detect){
                        match = Detect[i].exec(ua);
                        if(match){
                            tmp = Detect[i].exec(ua);
                        }  
                    }
                    N = {
                        system : tmp[1].toLowerCase(),
                        version : tmp[2].replace(/(\_|.)/ig, '.').toLowerCase(),
                        browser : browser ? browser[1].toLowerCase() : 'apple/webkit',
                        ios: ios
                    }
                    return N;
    } 

            

  • 相关阅读:
    ZYNQ. Interrupt(1)Private Timer
    RaspberryPi.1.开机与远程桌面
    ZYNQ. DMA基本用法
    ZYNQ. LwIP.PHY.KSZ9031RNX
    Verilog笔记.三段式状态机
    c语言.函数指针数组
    c语言学习笔记.链表.
    D3D基本框架:即D3D头文件分类
    win32窗口:关于鼠标定位位置偏移问题的原因及解决方法
    <转>C++基础知识: 引用
  • 原文地址:https://www.cnblogs.com/heimanba/p/3868863.html
Copyright © 2020-2023  润新知