DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Javascript Browser Check

10.02.2006
| 24959 views |
  • submit to reddit
        // the navigator object stores the browser and additional secifications

<html><head><title>JS Browser Check</title></head><body>

<script type="text/javascript">
document.write("Your browser is " + navigator.appName);

if (navigator.appVersion.substring(0, 1) == "4")
  document.write("4th generation browser!");
  
document.write("patform/os:" + navigator.platform);
document.write("user agent data:" + navigator.userAgent);

if (navigator.cookieEnabled == true) {
  document.write("cookies enabled");
} else if (navigator.cookieEnabled == false) {
  document.write("no cookies.");
} else {
  document.write("cookies? No Info available.");
}

if (navigator.javaEnabled()) {
  document.write("java enabled.");
} else {
  document.write("java not available.");
}

if (navigator.language.indexOf("en") > -1) {
  document.write("language ins english");
}else if (navigator.language.indexOf("de") > -1) {
  document.write("language is german");
}

</script>

</body></html>