Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Web
Expertise: Intermediate
Aug 7, 1998



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Sensing Browser Type

You can easily find out the browser type, version, and sometimes the operating system that your visitors are using by checking the userAgent and appVersion properties of the navigator object. Based on this information you can tailor the content that users see in a number of ways including, but not limited to, automatically taking them to the page most appropriate for the software they're using.
<SCRIPT Language="JavaScript">
  var uagent = navigator.userAgent;
  var appver = navigator.appVersion.substring(0,1);

  if (uagent.indexOf("MSIE") != -1) {
    document.write("Microsoft Internet Explorer<BR>");
  } else {
    if (uagent.indexOf("Mozilla") != -1) {
      document.write("Netscape Navigator<BR>");
    } else {
      document.write("Unknown browser");

  document.write("Version " + appver + "<BR>");
<BR><BR><H1>The browser type is shown above.</H1>
Boris Feldman
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date