Java script function to get browser name.

Virendradugar
Posted by Virendradugar under JavaScript category on | Views : 3553
We have this requirement in most of the application to know that which browser user is using to view the web site. We can use javascript to know browser name and this function works with all the broswers?

function GetBrowser()
{
if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent))
{
var ffversion=new Number(RegExp.$1)
if (ffversion>=3)
alert(?FF 3.x or above?)
else if (ffversion>=2)
alert(?FF 2.x?)
else if (ffversion>=1)
alert(?FF 1.x?)
}
else if(/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent))
{
alert(?Chrome.?);
}

else if(/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent))
{
alert(?Opera?);
}
else
{
alert(navigator.appName);
}

return false;
}

window.onload = GetBrowser;


Enjoy????..

Comments or Responses

Login to post response