JTLR
6/2/2014 - 2:25 PM

Function to detect and match a user agent string

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