Also see jsBrowsersDetect
This javascript allows you to show a message when the visitor is not using at least a minimum version of a web browser that your web page requires. For example, if you load this page in lesser versions of Internet Explorer 8, Firefox 3, Google Chrome 3, Opera 2 or Safari 528 you will get a message.
Source Code:
<script type="text/javascript" language="javascript">
window.onload = function() { checkBrowserCurrentVersion(); }
function checkBrowserCurrentVersion() {
/* This function checks for minimum browser versions and alerts visitor if browser version not met. Author Joe McCormack. www.virtualsecrets.com */
/* Minimum Browser Versions Required */
var minVersion_IE = 8;
var minVersion_FF = 3.5;
var minVersion_Chrome = 3;
var minVersion_Safari = 528;
var minVersion_Opera = 2;
/* Message To Show If Browser Version Is Less Than Version Required */
var browserMinVersionMsg = "This page may not work properly given the current version of the web browser you are using.";
/* Do not modify */
var current_browserDetect = navigator.userAgent.toLowerCase();
var current_browserName = "";
var current_browserVersion = 0;
var minBrowserVersionMet = 0;
var data = "";
if (current_browserDetect.indexOf("msie") > 0) {
broBlock = new Array();
broBlock = current_browserDetect.split("(")[1].split(")")[0].split(/\;/g);
for (x = 0; x < broBlock.length; x++) {
if (broBlock[x].indexOf("msie") > 0) {
broBlock[x] = broBlock[x].replace(/^\s+/, "");
broBlock[x] = broBlock[x].replace(/\s+$/, "");
current_browserName = broBlock[x].split(" ")[0];
current_browserVersion = broBlock[x].split(" ")[1];
}
}
if (current_browserVersion >= minVersion_IE) { minBrowserVersionMet = 1; }
}
else if (current_browserDetect.indexOf("firefox") > 0) {
data = current_browserDetect.split("firefox")[1].split(" ")[0];
data = data.replace(/^\//, "");
current_browserName = "firefox";
current_browserVersion = data;
if (parseFloat(current_browserVersion) >= parseFloat(minVersion_FF)) { minBrowserVersionMet = 1; }
}
else if (current_browserDetect.indexOf("chrome") > 0) {
data = current_browserDetect.split("chrome")[1].split(" ")[0];
data = data.replace(/^\//, "");
current_browserName = "chrome";
current_browserVersion = data;
if (parseFloat(current_browserVersion) >= parseFloat(minVersion_Chrome)) { minBrowserVersionMet = 1; }
}
else if (current_browserDetect.indexOf("safari") > 0) {
data = current_browserDetect.split("safari")[1].split(" ")[0];
data = data.replace(/^\//, "");
current_browserName = "safari";
current_browserVersion = data;
if (current_browserVersion >= minVersion_Safari) { minBrowserVersionMet = 1; }
}
else if (current_browserDetect.indexOf("opera") > -1) {
data = current_browserDetect.split("opera")[1].split(" ")[0];
data = data.replace(/^\//, "");
current_browserName = "opera";
current_browserVersion = data;
if (current_browserVersion >= minVersion_Opera) { minBrowserVersionMet = 1; }
}
else {
current_browserName = "Unknown";
current_browserVersion = 0;
minBrowserVersionMet = 1;
}
if (minBrowserVersionMet == 0) {
var compiled = "";
compiled = "Minimum Browser Version Not Met:\n\nBrowser: " + current_browserName.toUpperCase() + "\nVersion: " + current_browserVersion + "\n\n";
compiled = compiled + browserMinVersionMsg;
alert(compiled);
}
}
</script>