Skip to content

Instantly share code, notes, and snippets.

@elijahmanor
Last active December 10, 2015 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elijahmanor/4490679 to your computer and use it in GitHub Desktop.
Save elijahmanor/4490679 to your computer and use it in GitHub Desktop.
Example of Browser Sniffing Gone Bad
// Example of browser sniffing gone bad
var ieMatch = navigator.userAgent.match( /MSIE\s(\d)/ );
if ( ieMatch && parseInt( ieMatch[ 1 ], 10 ) >= 8 ) {
console.log( "IE 8+" );
} else {
console.log( "Feature Not Supported" );
}
// Prefered technique of determining feature support
if ( Modernizr.geolocation ) {
// Find the user's current location...
} else {
// Provide some sort of polyfill
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment