zoukankan      html  css  js  c++  java
  • 【通用】判断浏览器类型和版本

    1、判断浏览器是否为IE
            document.all ? 'IE' : 'others':在IE下document.all值为1,而其他浏览器下的值为0;
            navigator.userAgent.indexOf("MSIE")>0 ? 'IE' : 'others':navigator.userAgent是描述用户代理信息。
            navigator.appName.indexOf("Microsoft") != -1 ? 'IE' : 'others':navigator.appName描述浏览器名称信息。
    2、判断IE版本
            navigator.appVersion.match(/6./i)=="6." ? 'IE6' : 'other version':在已知是IE浏览器的情况下,可以通过此方法判断是否是IE6;
            navigator.userAgent.indexOf("MSIE 6.0")>0 ? 'IE7' : 'other version':同上;
            navigator.appVersion.match(/7./i)=="7." ? 'IE7' : 'other version':在已知是IE浏览器的情况下,可以通过此方法判断是否是IE7;
            navigator.userAgent.indexOf("MSIE 7.0")>0 ? 'IE7' : 'other version':同上;
            navigator.appVersion.match(/8./i)=="8." ? 'IE8' : 'other version':在已知是IE浏览器的情况下,可以通过此方法判断是否是IE8;
            navigator.userAgent.indexOf("MSIE 8.0")>0 ? 'IE8' : 'other version':同上。
    3、JS获取浏览器信息
            浏览器代码名称:navigator.appCodeName
            浏览器名称:navigator.appName
            浏览器版本号:navigator.appVersion
            对Java的支持:navigator.javaEnabled()
            MIME类型(数组):navigator.mimeTypes
            系统平台:navigator.platform
            插件(数组):navigator.plugins
            用户代理:navigator.userAgent

  • 相关阅读:
    Installshield制作安装程序
    vista以上系统中开发的程序以管理员权限运行
    检查当前系统版本是否为Vista或更高的版本
    在程序运行过程中调用另一个程序
    Spin Control(旋转按钮控件、上下微调按钮控件)
    因改变工具栏图标导致菜单栏高度随之变大的解决方案
    Unicode环境下的字符差异
    注册表API
    文件的读写操作
    const char* 和 char* const
  • 原文地址:https://www.cnblogs.com/toward-the-sun/p/4058973.html
Copyright © 2011-2022 走看看