Skip to content

Instantly share code, notes, and snippets.

@Davidslv
Created February 3, 2014 08:14
Show Gist options
  • Save Davidslv/8780370 to your computer and use it in GitHub Desktop.
Save Davidslv/8780370 to your computer and use it in GitHub Desktop.
jQuery bad code for browser detection
// Bad Code from Efytimes:
// http://efytimes.com/e1/fullnews.asp?edid=128774
// Please don't use this code in your website if you have jQuery > 1.9
$(document).ready(function() {
// If the browser type if Mozilla Firefox
if ($.browser.mozilla && $.browser.version >= "1.8" ){
// some code
}
// If the browser type is Opera
if( $.browser.opera)
{
// some code
}
// If the web browser type is Safari
if( $.browser.safari )
{
// some code
}
// If the web browser type is Chrome
if( $.browser.chrome)
{
// DON'T USE THIS, it will return undefined and your code will never run here.
// $.browser.webkit is the right one, same applies for $.browser.safari, use `webkit`
}
// If the web browser type is Internet Explorer
if ($.browser.msie && $.browser.version <= 6 )
{
// some code
}
//If the web browser type is Internet Explorer 6 and above
if ($.browser.msie && $.browser.version > 6)
{
// some code
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment