'$.browser.msie'empty or not an object's problem

Copyright Notice: This article was first published on my personal website Keyon Y , please indicate the source.

jQuery started with version 1.9, removing.browser and.browser.version Instead, $.support.IE 6/7/8 will no longer be supported in the updated version 2.0.
Solution 1:

<!--[if lt IE 9]>
<script src='/jquery-1.10.1.min.js'></script>
<![endif]-->
<!--[if gte IE 9]>
<script src='/jquery-2.0.2.min.js'></script>
<![endif]-->

Solution 2:
Just don't use $.Browser.msieTo judge, we have found some solutions that can be directly replaced on the Internet

$.browser.mozilla = /firefox/.test(navigator.userAgent.toLowerCase());
$.browser.webkit = /webkit/.test(navigator.userAgent.toLowerCase());
$.browser.opera = /opera/.test(navigator.userAgent.toLowerCase());
$.browser.msie = /msie/.test(navigator.userAgent.toLowerCase());

The expression after the equal sign returns true/false, which can be used directly to replace the original $.Browser.msieWait.
Check if IE6:

// Old
if ($.browser.msie && 7 > $.browser.version) {}
// New
if ('undefined' == typeof(document.body.style.maxHeight)) {}

Check if IE 6-8:
.Support.leadingWhitespaceIt is a unique property in IE, so it can be used.Support.leadingWhitespaceTo determine if the browser is IE6-8
Code One

if (!$.support.leadingWhitespace) {}

Code 2

$(function($){
  var ieFlag= $.support.leadingWhitespace;//Define variables to judge IE8
  if(!ieFlag){//Below IE8
   //IE Code
  }else{
   //Other Codes
  }
 });
 ```
//Solution 3
/*Later discoveries determine the common type of browser type*/An article written by a foreigner in IE,Firefox,Google Available below
//Original address: http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser

```javascript
// Firefox 1.0+
 var isFirefox = typeof InstallTrigger !== 'undefined';
 alert("isFirefox:"+isFirefox);
 // Opera 8.0+
 var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
 alert("isOpera:"+isOpera);
 // Safari <= 9 "[object HTMLElementConstructor]"
 var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
 alert("isSafari:"+isSafari);
 // Internet Explorer 6-11
 var isIE = /*@cc_on!@*/ false || !!document.documentMode;
 alert("isIE:"+isIE);
 // Edge 20+
 var isEdge = !isIE && !!window.StyleMedia;
 alert("isEdge:"+isEdge);
 // Chrome 1+
 var isChrome = !!window.chrome && !!window.chrome.webstore;
 alert("isChrome:"+isChrome);
 // Blink engine detection(7)
 var isBlink = (isChrome || isOpera) && !!window.CSS;
 alert("isBlink:"+isBlink);

Tags: IE Firefox JQuery Google

Posted on Sat, 04 Jul 2020 10:50:11 -0400 by shinstar