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');