Saturday 2 June 2012

How To Know the Browser Details


Through this example you will learn how to detect name, version, Code Name, Browser Language and more about visitor's browser.
Here I am writing a Script as follows:
<script type="text/javascript">
    var
x = navigator;
    document.write("<b> Browser Name:</b>" + x.appName);
    document.write("<br />");
    document.write("<br />");
    document.write("<b>Minor Version:</b>" + x.appMinorVersion);
    document.write("<br />");
    document.write("<br />");
    document.write("<b>Version:</b>" + x.appVersion);
    document.write("<br />");
    document.write("<br />");
    document.write("<b>Code Name:</b>" + x.appCodeName);
    document.write("<br />");
    document.write("<br />");
    document.write("<b>Cookie Enabled:</b>" + x.cookieEnabled);
    document.write("<br />");
    document.write("<br />");
    document.write("<b>CPU Class:</b>" + x.cpuClass);
    document.write("<br />");
    document.write("<br />");
    document.write("<b>OnLine:</b>" + x.onLine);
    document.write("<br />");
    document.write("<br />");
    document.write("<b>Platform:</b>" + x.platform);
    document.write("<br />");
    document.write("<br />");
    document.write("<b>User Agent:</b>" + x.userAgent);
    document.write("<br />");
    document.write("<br />");
    document.write("<b>Browser Language:</b>" + x.browserLanguage);
    document.write("<br />");
    document.write("<br />");
    document.write("<b>System Language:</b>" + x.systemLanguage);
    document.write("<br />");
    document.write("<br />");
    document.write("<b>User Language:</b>" + x.userLanguage);
</script>

Use this JavaScript within body tag like as follows:
<body>
    <
script type="text/javascript">
   
......
    ......

    </
script>
</
body>
The output of this script are different because this script is used to get the browser's detail. if you user InterNet Explorer then you will see following output.


Figure 1: InterNet Explore's Detail.
If you user Mozilla FireFox then you will see following output.



Figure 2: Mozilla FireFox's Detail.

If you user Google chrome then you will see following output.

Figure 3: Google chrome's Detail.
So by using this script you can get any browser's detail.

No comments:

Post a Comment