Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


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

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.
 
<HTML>
<HEAD>
<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>");
</SCRIPT>
</HEAD>
<BODY>
<BR><BR><H1>The browser type is shown above.</H1>
</BODY>
</HTML>
Boris Feldman
 
Comment and Contribute

 

 

 

 

 


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

 

 

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