Created
April 4, 2017 07:28
-
-
Save stefanRepac/b7678c7796e603791a17e3d6bddfb408 to your computer and use it in GitHub Desktop.
Browser detect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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