Created
June 2, 2014 14:25
-
-
Save JTLR/e4df95e9782868650b48 to your computer and use it in GitHub Desktop.
Function to detect and match a user agent string
This file contains hidden or 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
function detectFromUserAgentString(stringToMatch) { | |
var userAgentString = navigator.userAgent.toLowerCase(), | |
result; | |
if (userAgentString.search(stringToMatch) > -1) { | |
result = true; | |
} else { | |
result = false; | |
} | |
return result; | |
} | |
detectFromUserAgentString('iPhone'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment