Javascript to find Browser Name
by Subramanian[ Edit ] 2013-09-05 14:14:10
Javascript to find Browser Name
Hi, The below code is used to get the browser name.
function findBrowser()
{
var nAgt = navigator.userAgent;
// In Opera, the true version is after "Opera" or after "Version"
if (nAgt.indexOf("Opera")!=-1) {
browserName = "Opera";
}
// In MSIE, the true version is after "MSIE" in userAgent
else if (nAgt.indexOf("MSIE")!=-1) {
browserName = "Microsoft Internet Explorer";
}
// In Chrome, the true version is after "Chrome"
else if (nAgt.indexOf("Chrome")!=-1) {
browserName = "Chrome";
}
// In Safari, the true version is after "Safari" or after "Version"
else if (nAgt.indexOf("Safari")!=-1) {
browserName = "Safari";
}
// In Firefox, the true version is after "Firefox"
else if (nAgt.indexOf("Firefox")!=-1) {
browserName = "Firefox";
}
return browserName;
}