Skip to content

Instantly share code, notes, and snippets.

@interfeis
Created July 2, 2012 16:36
Show Gist options
  • Save interfeis/3034144 to your computer and use it in GitHub Desktop.
Save interfeis/3034144 to your computer and use it in GitHub Desktop.
Browser detection
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
if(ieversion>=9) {
//IE9
} else
if(ieversion>=8) {
//IE8
} else
if(ieversion>=7) {
//IE7
}
}
if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
if (ffversion>=5) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment