Using JavaScript to Determine What Browser Someone is Using.

26. November 2009 04:29

JavaScript has at its disposal a Navigator object that can be used to gain information about the browser that a web page visitor is using. This was highly beneficial in the past when there were more browsers that couldn’t run JavaScript. A separate version of the page could be set to run, depending on what browser the site visitor was using. It could also be used to tell visitors that there browser is too old to run a set of scripts that the website uses.

You can find out your browser’s information by referring to the Navigator object in your variable assignments.

 

<html>

<body>

<script type= “type/javascript”>

var browser=navigator.appName; //Tells you the name of your browser

var version=navigator.appVersion;//Tells you the version.

</script>

</body>

</html>

On an odd note, all versions of Internet Explorer 4.0 and above list 4 as their version number. The Navigator object can also be used to show the CPU and platform type of your system, the language setting of your system and browser, if cookies are enabled, and your minor version and User Agent. You can use the following code to display the attributes I mentioned.

 

function showAll()

{

var browser = navigator;

document.write("CodeName=" + browser.appCodeName);

document.write("MinorVersion=" + browser.appMinorVersion);

document.write("Name=" + browser.appName);

document.write("Version=" + browser.appVersion);

document.write("CookieEnabled=" + browser.cookieEnabled);

document.write("CPUClass=" + browser.cpuClass);

document.write("OnLine=" + browser.onLine);

document.write("Platform=" + browser.platform);

document.write("UA=" + browser.userAgent);

document.write("BrowserLanguage=" + browser.browserLanguage);

document.write("SystemLanguage=" + browser.systemLanguage);

document.write("UserLanguage=" + browser.userLanguage);

}

<input type="button" onclick="showAll()" value="Show Browser Details" />





Comments

2/21/2010 2:22:14 PM #

stock charts

Yes, I have been looking for this all week better now than never!

stock charts United States |

2/21/2010 11:25:33 PM #

Daniel Millions

Just wanted to say that you have some great content on your blog. If it's OK I would like to use some of it on my blog. If I link back to this page would it be OK to do so?

Daniel Millions United States |

4/28/2010 1:02:32 AM #

Rapidshare

I\'m happy I found this blog, I couldnt discover any info on this subject matter prior to. I also run a site and if you want to ever serious in a little bit of guest writing for me if possible feel free to let me know, i\'m always look for people to check out my site. Please stop by and leave a comment sometime!

Rapidshare United States |

5/24/2010 5:54:05 PM #

Edward

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts.Any way Ill be subscribing to your feed and I hope you post again soon Now, to most baseball memorabilia collectors, both items would be considered quality additions to their collections.

Edward People's Republic of China |

6/19/2010 8:26:58 AM #

no fax personal loans

I keep my ideals, because in spite of everything, I still believe that people are really good at heart.

no fax personal loans United States |

8/16/2010 7:57:08 AM #

paid to click on ads

I am so amazed at how terrific the info is on this webpage. I have written down this web site and I really  plan on visiting the site in the next few days. Keep up the fantastic work!

paid to click on ads United States |

Comments are closed


About the author

 The creators of the Web Design Blog have been creating web designs for over 12 years

Page List