zoukankan      html  css  js  c++  java
  • js怎么判断浏览器类型

    <script type=“text/javascript”>

    function isIE(){
    return navigator.appName.indexOf(“Microsoft Internet Explorer”)!=-1 && document.all;
    }

    function isIE6() {
    return navigator.userAgent.split(“;”)[1].toLowerCase().indexOf(“msie 6.0″)==“-1″?false:true;
    }

    function isIE7(){
    return navigator.userAgent.split(“;”)[1].toLowerCase().indexOf(“msie 7.0″)==“-1″?false:true;
    }

    function isIE8(){
    return navigator.userAgent.split(“;”)[1].toLowerCase().indexOf(“msie 8.0″)==“-1″?false:true;
    }

    function isNN(){
    return navigator.userAgent.indexOf(“Netscape”)!=-1;
    }

    function isOpera(){
    return navigator.appName.indexOf(“Opera”)!=-1;
    }

    function isFF(){
    return navigator.userAgent.indexOf(“Firefox”)!=-1;
    }

    function isChrome(){
    return navigator.userAgent.indexOf(“Chrome”) > -1;
    }
    </script>

    下面介绍下 js获取客户端浏览器信息

    Navigator 对象包含有关浏览器的信息。js就是通过Navigator的属性获取客户端浏览器信息
    Navigator 对象属性:

    属性
    描述

    appCodeName 返回浏览器的代码名。
    appMinorVersion 返回浏览器的次级版本。
    appName 返回浏览器的名称。
    appVersion 返回浏览器的平台和版本信息。
    browserLanguage 返回当前浏览器的语言。
    cookieEnabled 返回指明浏览器中是否启用 cookie 的布尔值。
    cpuClass 返回浏览器系统的 CPU 等级。
    onLine 返回指明系统是否处于脱机模式的布尔值。
    platform 返回运行浏览器的操作系统平台。
    systemLanguage 返回 OS 使用的默认语言。
    userAgent 返回由客户机发送服务器的 user-agent 头部的值。
    userLanguage 返回 OS 的自然语言设置。
  • 相关阅读:
    Pyinstaller(python打包为exe文件)
    matplotlib 填充颜色
    Visual Studio 2015 Enterprise
    latex中pdflatex与xelatex的区别
    latex插图续
    dva+umi+antd项目从搭建到使用(没有剖验证,不知道在说i什么)
    umi+dva+antd新建项目(亲测可用)
    HTTP缓存机制
    企业网站常见需求整理
    立足于运维与监控的前端框架 NoahV
  • 原文地址:https://www.cnblogs.com/ron123/p/3765068.html
Copyright © 2011-2022 走看看