Jquery1.9 is always used in the project, and browser objects are not supported. Baidu once found the solution. Here we will share with you that if you have encountered this problem, do not miss the recent project requirements, the cycle plug-in of jquery is used, but jquery1.9 is always used in the project. browser objects are not supported. Baidu finds the solution.
Add the following code to the source code of the cycle plug-in:
The Code is as follows:
(Function (jQuery ){
If (jQuery. browser) return;
JQuery. browser = {};
JQuery. browser. mozilla = false;
JQuery. browser. webkit = false;
JQuery. browser. opera = false;
JQuery. browser. msie = false;
Var nAgt = navigator. userAgent;
JQuery. browser. name = navigator. appName;
JQuery. browser. fullVersion = ''+ parseFloat (navigator. appVersion );
JQuery. browser. majorVersion = parseInt (navigator. appVersion, 10 );
Var nameOffset, verOffset, ix;
// In Opera, the true version is after "Opera" or after "Version"
If (verOffset = nAgt. indexOf ("Opera "))! =-1 ){
JQuery. browser. opera = true;
JQuery. browser. name = "Opera ";
JQuery. browser. fullVersion = nAgt. substring (verOffset + 6 );
If (verOffset = nAgt. indexOf ("Version "))! =-1)
JQuery. browser. fullVersion = nAgt. substring (verOffset + 8 );
}
// In MSIE, the true version is after "MSIE" in userAgent
Else if (verOffset = nAgt. indexOf ("MSIE "))! =-1 ){
JQuery. browser. msie = true;
JQuery. browser. name = "Microsoft Internet Explorer ";
JQuery. browser. fullVersion = nAgt. substring (verOffset + 5 );
}
// In Chrome, the true version is after "Chrome"
Else if (verOffset = nAgt. indexOf ("Chrome "))! =-1 ){
JQuery. browser. webkit = true;
JQuery. browser. name = "Chrome ";
JQuery. browser. fullVersion = nAgt. substring (verOffset + 7 );
}
// In Safari, the true version is after "Safari" or after "Version"
Else if (verOffset = nAgt. indexOf ("Safari "))! =-1 ){
JQuery. browser. webkit = true;
JQuery. browser. name = "Safari ";
JQuery. browser. fullVersion = nAgt. substring (verOffset + 7 );
If (verOffset = nAgt. indexOf ("Version "))! =-1)
JQuery. browser. fullVersion = nAgt. substring (verOffset + 8 );
}
// In Firefox, the true version is after "Firefox"
Else if (verOffset = nAgt. indexOf ("Firefox "))! =-1 ){
JQuery. browser. mozilla = true;
JQuery. browser. name = "Firefox ";
JQuery. browser. fullVersion = nAgt. substring (verOffset + 8 );
}
// In most other browsers, "name/version" is at the end of userAgent
Else if (nameOffset = nAgt. lastIndexOf ('') + 1) <
(VerOffset = nAgt. lastIndexOf ('/')))
{
JQuery. browser. name = nAgt. substring (nameOffset, verOffset );
JQuery. browser. fullVersion = nAgt. substring (verOffset + 1 );
If (jQuery. browser. name. toLowerCase () = jQuery. browser. name. toUpperCase ()){
JQuery. browser. name = navigator. appName;
}
}
// Trim the fullVersion string at semicolon/space if present
If (ix = jQuery. browser. fullVersion. indexOf (";"))! =-1)
JQuery. browser. fullVersion = jQuery. browser. fullVersion. substring (0, ix );
If (ix = jQuery. browser. fullVersion. indexOf (""))! =-1)
JQuery. browser. fullVersion = jQuery. browser. fullVersion. substring (0, ix );
JQuery. browser. majorVersion = parseInt (''+ jQuery. browser. fullVersion, 10 );
If (isNaN (jQuery. browser. majorVersion )){
JQuery. browser. fullVersion = ''+ parseFloat (navigator. appVersion );
JQuery. browser. majorVersion = parseInt (navigator. appVersion, 10 );
}
JQuery. browser. version = jQuery. browser. majorVersion;
}) (JQuery );
This Code specifically solves the problem that browser objects are not supported.