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

    if(window.navigator.userAgent.toLowerCase().indexOf("msie") > 0){

        return “IE”;

    }

    if(window.navigator.userAgent.toLowerCase().indexOf("msie 8.0") > -1){

        return “IE 8”;

    }

    firefox判断应该是ua.match(/firefox[/s](d+)/);

    var isIE=!!window.ActiveXObject; 
    var isIE6=isIE&&!window.XMLHttpRequest; 
    var isIE8=isIE&&!!document.documentMode; 
    var isIE7=isIE&&!isIE6&&!isIE8; 
    if (isIE){ 
    if (isIE6){ 
    alert("ie6"); 
    }else if (isIE8){ 
    alert("ie8"); 
    }else if (isIE7){ 
    alert("ie7"); 

    f(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/6./i)=="6."){ 
    alert("IE 6"); 

    else if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/7./i)=="7."){ 
    alert("IE 7"); 

    else if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/8./i)=="8."){ 
    alert("IE 8"); 

    else if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/9./i)=="9."){ 
    alert("IE 9"); 

    if(navigator.userAgent.indexOf("Opera") != -1) { 
    alert('Opera'); 

    else if(navigator.userAgent.indexOf("MSIE") != -1) { 
    alert('Internet Explorer'); 

    else if(navigator.userAgent.indexOf("Firefox") != -1) { 
    alert('Firefox'); 

    else if(navigator.userAgent.indexOf("Netscape") != -1) { 
    alert('Netscape'); 

    else if(navigator.userAgent.indexOf("Safari") != -1) { 
    alert('Safari'); 

    else{ 
    alert('无法识别的浏览器。'); 

  • 相关阅读:
    10.23 JSTL
    10.22 EL执行表达式
    10.21 EL表达式(只能在jsp中使用)
    10.20 网站访问量统计(application)
    10.19 JSP内置对象作用域
    10.16 Session和Cookie的区别
    10.15 转发与重定向
    剑指Offer_26_二叉搜索树与双向链表
    剑指Offer_25_复杂链表的复制
    剑指Offer_24_二叉树中和为某一值的路径.md
  • 原文地址:https://www.cnblogs.com/fang51/p/4496776.html
Copyright © 2011-2022 走看看