Suporte ao navegador

// We want to alert the user if they are using an outdated browser.

// First, we need to check if the browser is supported.
// We can do this by checking the browser's version.
// If the browser's version is less than or equal to 8, we can alert the user.
browserSupport = function() {
    var browser = navigator.appName;
    var version = navigator.appVersion;
    var majorVersion = parseInt(navigator.appVersion, 10);
    var nameOffset, verOffset, ix;
    
    // In Opera, the true version is after "Opera" or after "Version"
    if ((verOffset = version.indexOf("Opera")) != -1) {
        browser = "Opera";
        version = version.substring(verOffset + 6);
    }
    // In MSIE, the true version is after "MSIE" in userAgent
    else if ((verOffset = version.indexOf("MSIE")) != -1) {
        browser = "Microsoft Internet Explorer";
        version = version.substring(verOffset + 5);
    }
    // In Chrome, the true version is after "Chrome"
    else if ((verOffset = version.indexOf("Chrome")) != -1) {
        browser = "Chrome";
        version = version.substring(verOffset + 7);
    }
    // In Safari, the true version is after "Safari" or after "Version"
    else if ((verOffset = version.indexOf("Safari")) != -1) {
        browser = "Safari";
        version = version.substring(verOffset + 7);
    }
    // In Firefox, the true version is after "Firefox"
    else if ((verOffset = version.indexOf("Firefox")) != -1) {
        browser = "Firefox";
        version = version.substring(verOffset + 8);
    }
    // In most other browsers, "name/version" is at the end of userAgent
    else if ((nameOffset = userAgent.lastIndexOf(' ') + 1) < (verOffset = userAgent.lastIndexOf('/'))) {
        browser = userAgent.substring(nameOffset, verOffset);
        version = userAgent.substring(verOffset + 1);
        if (browser.toLowerCase() == browser.toUpperCase()) {
            browser = navigator.appName;
        }
    }
    // trim the version string
    if ((ix = version.indexOf(";")) != -1) version = version.substring(0, ix);
    if ((ix = version.indexOf(" ")) != -1) version = version.substring(0, ix);
    if ((ix = version.indexOf("/")) != -1) version = version.substring(0, ix);
    
    // majorVersion is the major version of the browser
    majorVersion = parseInt('' + version, 10);

    // If the browser is not supported, alert the user.
    if (browser == "Microsoft Internet Explorer" && majorVersion < 8) {
        alert("Your browser is not supported. Please upgrade your browser to continue.");
        return false;
    }
    else if (browser == "Firefox" && majorVersion < 3) {
        alert("Your browser is not supported. Please upgrade your browser to continue.");
        return false;
    }
    else if (browser == "Chrome" && majorVersion < 4) {
        alert("Your browser is not supported. Please upgrade your browser to continue.");
        return false;
    }
    else if (browser == "Safari" && majorVersion < 5) {
        alert("Your browser is not supported. Please upgrade your browser to continue.");
        return false;
    }
    else if (browser == "Opera" && majorVersion < 11) {
        alert("Your browser is not supported. Please upgrade your browser to continue.");
        return false;
    }
    else {
        return true;
    }
}

// If the browser is supported, we can continue.
if (browserSupport()) {
    // We can continue.
}

// Run the function.
browserSupport();

// End of browser support.
Old-fashioned Otter