PDA

View Full Version : Check Browser Version and redirect



davelf
01-20-2016, 04:42 AM
Hi, i try this script to check browser version and redirect the user to update their browser:


function get_browser_version(){
var N=navigator.appName, ua=navigator.userAgent, tem;
var M=ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
if(M && (tem= ua.match(/version\/([\.\d]+)/i))!= null) M[2]= tem[1];
M=M? [M[1], M[2]]: [N, navigator.appVersion, '-?'];
return M[1];
}

var browser = navigator.appName;
var version = get_browser_version();

if (browser=="Microsoft Internet Explorer") {
if (version<="9.1")
document.location.href="upgrade.php"
}
if (browser=="Safari") {
if (version<="6.0")
document.location.href="upgrade.php"
}
if (browser=="Firefox") {
if (version<="5.0")
ddocument.location.href="upgrade.php"
}
if (browser=="Chrome") {
if (version<="15.0")
document.location.href="upgrade.php"
}
if (browser=="Opera") {
if (version<="11.10")
document.location.href="upgrade.php"
}


It work prefectly for Internet Explorer but not the other browser, is there something wrong with my script here?:confused: