Skip to content

Instantly share code, notes, and snippets.

@JTLR
Created June 2, 2014 14:25
Show Gist options
  • Save JTLR/e4df95e9782868650b48 to your computer and use it in GitHub Desktop.
Save JTLR/e4df95e9782868650b48 to your computer and use it in GitHub Desktop.
Function to detect and match a user agent string
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