判断IE版本与各浏览器的语句

---恢复内容开始---

一.IE下判断IE版本的语句

<!--[if lte IE 6]>
<![endif]-->
IE6及其以下版本可见
  
<!--[if lte IE 7]>
<![endif]-->
IE7及其以下版本可见
  
<!--[if IE 6]>
<![endif]-->
只有IE6版本可见
  
<![if !IE]>
<![endif]>
除了IE以外的版本
  
<!--[if lt IE 8]>
<![endif]-->
IE8以下的版本可见
  
<!--[if gte IE 7]>
<![endif]-->
 
IE7及大于IE7的版本可见
lte:就是Less than or equal to的简写,也就是小于或等于的意思。
lt :就是Less than的简写,也就是小于的意思。
gte:就是Greater than or equal to的简写,也就是大于或等于的意思。
gt :就是Greater than的简写,也就是大于的意思。
! : 就是不等于的意思,跟javascript里的不等于判断符相同
 
原文地址 http://www.jb51.net/article/83366.htm

二.判断各浏览器版本

if(navigator.userAgent.indexOf("Chrome") > -1){
    // 即是chrome
}

  

IE7:"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"
IE8:"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)"
IE9:"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
IE10:"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)"
Edge:"Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; GWX:RESERVED; rv:11.0) like Gecko"
Firefox:"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0"
Chrome:"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"

原文地址:https://segmentfault.com/q/1010000008821197

三.判断ie版本

$.support.leadingWhitespace为IE中特有的属性,因此可以利用$.support.leadingWhitespace来判断浏览器是否是IE6-8

$(function($){
            var ieFlag=  $.support.leadingWhitespace;//定义判断IE8的变量
              if(!ieFlag){//IE8以下
                 //IE代码
              }else{
                 //其他代码
              }
        });

原文地址:https://www.cnblogs.com/snn0605/p/5966371.html

猜你喜欢

转载自www.cnblogs.com/liyouwu/p/9019253.html