How to Detect Visitor's Browser Using JavaScript?

How to Detect Visitor's Browser Using JavascriptYou can detect which and what version of browser have used by your website visitors by using simple JavaScript codes. The navigator object in JavaScript contains information about the visitor's browser. It includes information about the visitor's browser name, browser version and more. It can be very useful to detect the visitor's browser type and version, and then serve up the appropriate information. By using this feature in JavaScript, it is easier to make your web pages smart enough to look one way to some browsers and another way to other browsers. But it may not be work for some browsers, specially for older browsers, which do not support JavaScript.

Here are some steps and codes for detecting visitor's browser using JavaScript, it may help you to apply this feature in your website.

Code for Detecting Visitor's Browser and Browser Version Using JavaScript

<script type="text/javascript">
var x=navigator

document.write("Name=" + x.appName)
document.write("Version=" + x.appVersion)
document.write("CookieEnabled=" + x.cookieEnabled)
document.write("BrowserLanguage=" + x.browserLanguage)
document.write("SystemLanguage=" + x.systemLanguage)
document.write("UserLanguage=" + x.userLanguage)


  • appName - It holds the application name of the browser.
  • appVersion - It holds the version of the application and other things.
  • cookieEnabled - It checks whether or not cookie is enabled.
  • browserLanguage - It holds the browser Language.
  • systemLanguage - It holds the system Language.
  • userLanguage - It holds the user Language.

Output of the Code for Detecting Visitor's Browser and Browser Version 

Example: Alert user for older browser

You can alert or inform the visitor of  your website by using navigator object in JavaScript as the following. Here in the given code, the browsers below the version 4 are treated as older browser and displays the message. You can also add the links to download the latest version of browsers. 

<script type="text/javascript">

var browser= x.appName
var version = parseFloat(x.appVersion)

if((browser="Netscape" || browser=="Microsoft Internet Explorer") && (version>=4))

{document.write("Your browser is good enough!")

{document.write("Your browser is old Update browser!")


Output of the above Code