利用$.support.leadingWhitespace检查浏览器是否为IE6-8

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

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

/*与标题无关*/

jQuery 从 1.9 版开始,移除了 $.browser 和 $.browser.version , 取而代之的是 $.support 。 在更新的 2.0 版本中,将不再支持 IE 6/7/8。 以后,如果用户需要支持 IE 6/7/8,只能使用 jQuery 1.9。 如果要全面支持 IE,并混合使用 jQuery 1.9 和 2.0,

官方的解决方案是:

1 <!--[if lt IE 9]>
2     <script src=‘jquery-1.9.0.js‘></script>
3 <![endif]-->
4 <!--[if gte IE 9]>
5     <script src=‘jquery-2.0.0.js‘></script>
6 <![endif]-->

/*后发现的判断浏览器类型通用类型*/老外写的一篇文章,在IE、Firefox、Google下亲测可用

原文地址:http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser

 1         // Firefox 1.0+
 2         var isFirefox = typeof InstallTrigger !== ‘undefined‘;
 3         alert("isFirefox:"+isFirefox);
 4         // Opera 8.0+
 5         var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(‘ OPR/‘) >= 0;
 6         alert("isOpera:"+isOpera);
 7         // Safari <= 9 "[object HTMLElementConstructor]"
 8         var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf(‘Constructor‘) > 0;
 9         alert("isSafari:"+isSafari);
10         // Internet Explorer 6-11
11         var isIE = /*@[email protected]*/ false || !!document.documentMode;
12         alert("isIE:"+isIE);
13         // Edge 20+
14         var isEdge = !isIE && !!window.StyleMedia;
15         alert("isEdge:"+isEdge);
16         // Chrome 1+
17         var isChrome = !!window.chrome && !!window.chrome.webstore;
18         alert("isChrome:"+isChrome);
19         // Blink engine detection(7)
20         var isBlink = (isChrome || isOpera) && !!window.CSS;
21         alert("isBlink:"+isBlink);

英文分析,原文贴过来:Analysis of reliability

The previous method depended on properties of the rendering engine (-moz-box-sizing and -webkit-transform) to detect the browser. These prefixes will eventually be dropped, so to make detection even more robust, I switched to browser-specific characteristics:

  • Internet Explorer: JScript‘s Conditional compilation (up until IE9) and document.documentMode.
  • Edge: In Trident and Edge browsers, Microsoft‘s implementation exposes the StyleMediaconstructor. Excluding Trident leaves us with Edge.
  • Firefox: Firefox‘s API to install add-ons: InstallTrigger
  • Chrome: The global chrome object, containing several properties including a documented chrome.webstore object.
  • Safari: A unique naming pattern in its naming of constructors. This is the least durable method of all listed properties, because it‘s undocumented. On the other hand, there‘s no benefit in renaming the constructor, so it‘s likely to stay for a long while.
  • Opera: window.opera has existed for years, but will be dropped when Opera replaces its engine with Blink + V8 (used by Chromium).
    • Update 1: Opera 15 has been released, its UA string looks like Chrome, but with the addition of "OPR". In this version the chrome object is defined (but chrome.webstore isn‘t). Since Opera tries hard to clone Chrome, I use user agent sniffing for this purpose.
    • Update 2: !!window.opr && opr.addons can be used to detect Opera 20+ (evergreen).
  • Blink: CSS.supports() was introduced in Blink once Google switched on Chrome 28. It‘s of course the same Blink used in Opera.
时间: 2024-08-26 09:26:05

利用$.support.leadingWhitespace检查浏览器是否为IE6-8的相关文章

js关闭浏览器窗口及检查浏览器关闭事件

js关闭浏览器窗口,不弹出提示框.支持ie6+,火狐,谷歌等浏览器,下面以一个示例为大家详细介绍下具体的实现方法,感兴趣的朋友可以参考下 js关闭浏览器窗口 js关闭浏览器窗口,不弹出提示框.支持ie6+,火狐,谷歌等浏览器. <html> <head /> <body> <script type="text/javascript"> function closeWin(){ window.opener=null; window.open

前端编程提高之旅(三)----浏览器兼容之IE6

在爱奇艺实习期间,乐帝主要负责移动端活动页面的制作,由于移动浏览器是随着智能手机兴起的,这就决定了移动端不会重蹈浏览器兼容问题的覆辙,一开始就比较好的支持web标准,而纵观整个互联网行业,移动web开发还处于起步阶段,在很长一段时间pc端web作为主要的服务形式还会继续.从小来说作为一名前端开发人员,不了解浏览器兼容也会贻笑大方.这篇文章基于<IE7web标准之道>,对浏览器兼容做一个概览.    时间到了2014年,大概很少人会想到IE7发布之后,时隔这么多年IE6仍然占据市场7%的浏览器份

检查浏览器

ecology8虽说支持主流浏览器访问,实测IE内核使用时,性能不佳,且偶尔还是有问题,谷歌(Webkit)内核效果最好.而且在进行JS二次开发时,处理浏览器兼容性问题是令人很头疼的事情.本段代码简单粗暴,谷歌内核的浏览器可以打开,其他浏览器就退出. /**检查浏览器是否是Webkit内核 */ function checkBrowser(){ if ((navigator.userAgent.indexOf('Chrome') ==-1)) {//从浏览器信息中查找”Chrome“字眼 var

Modernizr插件,检查浏览器是否支持某些功能,可定制

下面是官方的下载首页:http://modernizr.com/download/ 偶然间发现Modernizr插件,可以很方便的帮助我们检查客户端浏览器是否支持某些html5元素.css属性.使用起来,非常简单,例如:if(Modernizr.canvas){ console.log("支持Canvas");}. 通过firebug,我们可以清楚的看到Modernizr内部DOM结构:

JS检查浏览器类型和版本

先取得Navigator对象的userAgent属性的小写信息,之后根据正则表达式判断赋值. var Sys = {}; var ua = navigator.userAgent.toLowerCase(); var s; var scan; (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] : (s = ua .match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] : (s = ua .match(/ch

常见浏览器bug(针对IE6及更低版本)及其修复方法

常见bug及其修复方法有以下几种 1.双外边距浮动bug 双外边距浮动bug在IE6及更低版本中常见.所谓双外边距浮动bug是指使任何浮动元素上的外边距加倍.(见下图) 只要将元素的display属性设置成inline就行了.因为元素时浮动的,所以将display属性设置为inline实际上不会影响显示方式.但是,这似乎会阻止Windows上的IE6及更低版本将所有外边距加倍.所以每当对具有水平外边距的元素浮动时,都应该很自然的将display属性设置为inline,以备外边距将来被加大. 2.

JS检查浏览器类型和版本号

先取得Navigator对象的userAgent属性的小写信息,之后依据正則表達式推断赋值. var Sys = {}; var ua = navigator.userAgent.toLowerCase(); var s; var scan; (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] : (s = ua .match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] : (s = ua .match(/ch

判断浏览器是否为IE6

;(function(){ var isIE6 = !-[1,] && !window.XMLHttpRequest; if(isIE6){ alert('亲,您使用的浏览器版本过低,建议您升级浏览器以获得更好的效果体验!'); location.href('http://windows.microsoft.com/zh-cn/internet-explorer/download-ie'); } })();

提示:“请检查浏览器代理设置”/xx-net

1.删除已导入的证书文件(运行certmgr.msc和certlm.msc,然后自己找到xxnet删),2.更新3.3.1(或是自己找到那行代码取消注释,楼下有人提及)3.删除data文件夹(下的certs文件夹和CA.crt文件)4.正常初始化(反正到这就结束了吧?,进入正常流程了)重新导入xxnet证书 如果是其他系统请自行搜索相应的删除证书方法.注意删除证书一定要在4之前做,12的顺序其实随便来