Get browser type by using the navigator.userAgent : userAgent « Navigator « JavaScript Tutorial






<html>
<head>
<script language="JavaScript" type = "text/javascript">
<!--
var bname = "browser";
if (navigator.userAgent.indexOf("MSIE") != -1)
{
 bname = "Internet Explorer";
}
else if (navigator.userAgent.indexOf("Opera") != -1)
{
 bname = "Opera";
}
else if ((navigator.appName.indexOf("Netscape") != -1) || parseFloat(navigator.appVersion >= 3.0))
{
 bname = "Netscape Navigator";
}
else
{
 bname = "Unknown Browser";
}
document.write("Your browser is: " + bname);
//-->
</script>
<title>Display Browser Information</title>
</head>
<body>
</body>
</html>








17.7.userAgent
17.7.1.Get browser type by using the navigator.userAgent
17.7.2.navigator.userAgent