![How to Detect Visitor's Browser Using Javascript How to Detect Visitor's Browser Using Javascript](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYISrBCgU-NDIoupBM1Uu3Db2TdxjklKgG2hRtZ1d21Y51rMJVub1Hmrgp8KcrPJY5Jsg9GEqJcBtTpqIkobISGy-g8hnc1EHXLWO6G-wsW01uHC4a3XMhVUYAh5T-rbB1I2VYeGPr0qMl/s1600/browserdection.png)
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("<br/>")
document.write("Version=" + x.appVersion)
document.write("<br/>")
document.write("CookieEnabled=" + x.cookieEnabled)
document.write("<br/>")
document.write("BrowserLanguage=" + x.browserLanguage)
document.write("<br/>")
document.write("SystemLanguage=" + x.systemLanguage)
document.write("<br/>")
document.write("UserLanguage=" + x.userLanguage)
</script>
Where:
- 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("<br/>")}
else
{document.write("Your browser is old Update browser!")
document.write("<br/>")}
</script>
Output of the above Code
Related Posts
- How To Create Simple Image Slideshow Using JavaScript ?
- How to Create Simple JavaScript Fade Effect Animation?
- Image Slideshow with Navigation Buttons Using Javascript
- How to Create JavaScript Image Slideshow with Links
- Simple JavaScript Fade Effect Animation Using Jquery
- How to Create Simple JavaScript Fade Effect Animation?