Thursday, April 20, 2017

[JQuery] Detect browser with jQuery

You can use jQuery.browser which return a PlainObject to check. However, please note that jQuery Migrate plugin is required if you are using jQuery 1.9 or later.

I created a demo uses jQuery version 1.8.3. There is the Demo:

There is another sample code you can copy for test:
if ($.browser.chrome) {
     alert("You are using Google Chrome");  
}else if ($.browser.mozilla) {
     alert("You are using Mozilla FireFox.");
}else if ($.browser.msie) {
     alert("You are using Internet Explorer");
}else if ($.browser.opera) {
     alert("You are using Opera");
}else{
     alert("You are using other browsers.");
}

Reference:

https://api.jquery.com/jquery.browser/

No comments :

Post a Comment