zoukankan      html  css  js  c++  java
  • Jq_浏览器兼容性及其浏览器版本

    JQuery 中用 方法 jQuery.browser 来判断浏览器,返回值可以为: safari opera msie mozilla。

    当然有时候我们还需要区分版本 这就要用到 jQuery.browser.version  

    function JudgeBroswer() { 
            if($.browser.msie) { 
                alert("this is msie!"); //IE
            } 
            else if($.browser.safari) 
            { 
                alert("this is safari!"); //Safari 
            } 
            else if($.browser.mozilla) 
            { 
                alert("this is mozilla!");  //Firefox
            } 
            else if($.browser.opera) { 
                alert("this is opera");     //Opera
            } 
        }
    Code
    var userAgent = navigator.userAgent.toLowerCase();
        // Figure out what browser is being used 
        jQuery.browser = {
            version: (userAgent.match(/.+(?:rv|it|ra|ie)[/: ]([d.]+)/) || [])[1],
            safari: /webkit/.test(userAgent),
            opera: /opera/.test(userAgent),
            msie: /msie/.test(userAgent) && !/opera/.test(userAgent),
            mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent)
        };
    Code

    jQuery 使用的是通过正则来匹配userAgent判断浏览器的种类和版本.
    如果我们要来判断当前浏览器是否是IE6应该如何来判断?

    $.browser.msie&&($.browser.version == "6.0")&&!$.support.style 

    同样jQuery判断浏览器是否为IE7

    $.browser.msie&&($.browser.version == "7.0") 
  • 相关阅读:
    Asp.net Report动态生成
    Select2控件不能自适应的解决办法
    Bootstrap table 行编辑导航
    android – 无法解析AppCompatActivity
    Aspnet mvc移除WebFormViewEngine
    Android串口开发
    阿里云OCR图片转换成文字识别调用
    EF6实现软删除
    Audio播放
    asp.net webapi 的Request如何获取参数
  • 原文地址:https://www.cnblogs.com/ingstyle/p/4079089.html
Copyright © 2011-2022 走看看