does anyone have a script for checking for old browsers. It would have to follow this criteria:
Allow firefox 3.6 or up
Allow Google Chrome 15 and up
Allow Safari 5 or up
Block IE and opera
Block all other browsers
does anyone have a script for checking for old browsers. It would have to follow this criteria:
Allow firefox 3.6 or up
Allow Google Chrome 15 and up
Allow Safari 5 or up
Block IE and opera
Block all other browsers
You can use navigator
object for this and in that you can use userAgent
property like
if (navigator.userAgent.indexOf('Firefox') != -1 && parseFloat(navigator.userAgent.substring(navigator.userAgent.indexOf('Firefox') + 8)) >= 3.6){//Firefox
//Allow
}else if (navigator.userAgent.indexOf('Chrome') != -1 && parseFloat(navigator.userAgent.substring(navigator.userAgent.indexOf('Chrome') + 7).split(' ')[0]) >= 15){//Chrome
//Allow
}else if(navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Version') != -1 && parseFloat(navigator.userAgent.substring(navigator.userAgent.indexOf('Version') + 8).split(' ')[0]) >= 5){//Safari
//Allow
}else{
// Block
}
I agree with with @Sirko. Preferably, you should use feature-detection instead. An alternative to to Modernizr would be jQuery's $.support()
function. It's not exactly the same thing, but it may suit your needs.
If you insist on browser-detection, you can write your own script using jQuery's $.browser()
function.