I would like to show a pop-up telling the user if their browser is outdated. How can I find out what browser they are using in javascript?
Asked
Active
Viewed 1.1k times
3 Answers
5
function BrowserDetection() {
if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
var ffversion = new Number(RegExp.$1) ;
}
else if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
var ieversion = new Number(RegExp.$1);
}
else if (/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
var chromeversion = new Number(RegExp.$1);
// capture x.x portion and store as a number
}
else if (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
var oprversion = new Number(RegExp.$1)
}
else if (/Safari[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
var safariversion = new Number(RegExp.$1);
}
}
Then after finding the version, u will compare and display popup according to your need.

Community
- 1
- 1

Venkatesh Appala
- 4,320
- 2
- 20
- 13
1
Don't detect browsers, detect browser features. There's a good discussion on Stack Overflow already:

Community
- 1
- 1

a paid nerd
- 30,702
- 30
- 134
- 179
-
2This isn't an answser to the question. Who care's what people think. – Bryan Grace Oct 12 '16 at 17:48