articles

Home / DeveloperSection / Articles / Detecting Browser Capability in Java Script

Detecting Browser Capability in Java Script

Anonymous User7222 12-Mar-2011

We know that java script work with client side browsers. Sometimes we want to know some information about client browser such as version number, name, and support cookie functionality or not. Depends upon the browser we send different-different pages and functionalities. The Navigator object contains information about the visitor's browser name, version, and more. Following table describes some common functionality regarding browser detection.

Property:
  •   appCodeName  :  Provides code name of browser.
  •   appName   :  Provides name of the browser that user use for viewing browser.
  •   appVersion  :  Provides description of the version of browser.
  •   cookieEnabled   :  Checks whether browser support whether cookie   functionality enabled or not.
Following example demonstrate use of browser capability in java script
<script type="text/javascript">
        function detectBrowser() {
            document.write("Browser code name  : " + navigator.appCodeName + "<br />");
            document.write("Browser Name  : " + navigator.appName + "<br />");
            document.write("Browser Version  : " + navigator.appVersion + "<br />");
            document.write("Cookie Enabled  :  " + navigator.cookieEnabled + "<br />");
            document.write("Plateform  : " + navigator.platform + "<br />");
            document.write("User Agent Header  : " + navigator.userAgent + "<br />");
        }
</script>
Output of the following code snippet is as follows

Browser code name : Mozilla
Browser Name : Microsoft Internet Explorer
Browser Version : 4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; .NET4.0E)
Cookie Enabled : true
Platform : Win32
User Agent Header : Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; .NET4.0E)



Updated 04-Aug-2019
I am a content writter !

Leave Comment

Comments

Liked By