Skip to content

Instantly share code, notes, and snippets.

@Soullighter
Created April 4, 2017 07:28
Show Gist options
  • Save Soullighter/b7678c7796e603791a17e3d6bddfb408 to your computer and use it in GitHub Desktop.
Save Soullighter/b7678c7796e603791a17e3d6bddfb408 to your computer and use it in GitHub Desktop.
Browser detect
$(document).ready(function(){
/* Get browser */
$.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());
/* Detect Chrome */
if($.browser.chrome){
/* Do something for Chrome at this point */
alert("You are using Chrome!");
/* Finally, if it is Chrome then jQuery thinks it's
Safari so we have to tell it isn't */
$.browser.safari = false;
}
/* Detect Safari */
if($.browser.safari){
/* Do something for Safari */
alert("You are using Safari!");
}
});
$(document).ready(function() {
if ($.browser.mozilla && $.browser.version >= "2.0" ){
alert('Mozilla above 1.9');
}
if( $.browser.safari ){
alert('Safari');
}
if( $.browser.opera){
alert('Opera');
}
if ($.browser.msie && $.browser.version <= 6 ){
alert('IE 6 or below version');
}
if ($.browser.msie && $.browser.version > 6){
alert('IE above 6');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment