In jquery, you can use the "jQuery.browser" method to determine the browser type. It can return relevant information about the browser currently used by the user and determine the syntax "if($.browser.msie) {/ /is ie browser}".
The operating environment of this tutorial: windows7 system, jquery1.8 version, this method is suitable for all brands of computers.
Recommended tutorial: jquery video tutorial
JQuery can use the jQuery.browser method to determine the browser type. This method can return relevant information about the browser currently used by the user. .
Parameters:
webkit Boolean type indicates whether it is a browser with webkit core.
safari Boolean type indicates whether it is the Apple Safari browser.
opera Boolean type indicates whether it is an opera browser.
msie Boolean type indicates whether it is Microsoft IE browser.
mozilla Boolean type indicates whether it is a Mozilla FireFox browser.
chrome Boolean type indicates whether it is the Google Chrome browser.
version String type The version number of the current browser, for example: "6.0", "7.0".
Example:
function JudgeBroswer() { if($.browser.msie) { alert("this is msie!"); //IE } else if($.browser.safari) { alert("this is safari!"); //Safari } else if($.browser.mozilla) { alert("this is mozilla!"); //Firefox } else if($.browser.opera) { alert("this is opera"); //Opera } }
JQuery Source code:
var userAgent = navigator.userAgent.toLowerCase(); // Figure out what browser is being used jQuery.browser = { version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1], safari: /webkit/.test(userAgent), opera: /opera/.test(userAgent), msie: /msie/.test(userAgent) && !/opera/.test(userAgent), mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent) };
For more programming-related knowledge, please visit: Introduction to Programming! !
The above is the detailed content of How does jquery determine whether it is an IE browser?. For more information, please follow other related articles on the PHP Chinese website!