Last active
December 10, 2015 20:48
-
-
Save elijahmanor/4490679 to your computer and use it in GitHub Desktop.
Example of Browser Sniffing Gone Bad
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
// 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" ); | |
} |
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
// 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