
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How can you detect the version of a browser using Javascript?
In this article, we are going to discuss how to detect the version of a browser using JavaScript.
These days, most browsers are JavaScript−enabled. But still, there are some browsers that don’t support JavaScript; or, some versions of some browsers don’t support certain features of JavaScript.
Therefore, in certain instances, there is a need to know the details of the client’s web browser so that the applications can deliver appropriate content.
Detecting the Version of a Browser
You can detect the details of the current browser using navigator.appName and navigator.appVersion properties.
To detect the version of the browser in the JavaScript we need to use navigator.appVersion or navigator.userAgent. The navigator.appVersion is a read-only property and it returns a string and represents the version information of the browser.
Example 1
In the following example, we are demonstrating the navigator.appversion to find the version and details of the browser.
<!DOCTYPE html> <html lang="en"> <head> <title>Navigator</title> </head> <body> <h3>Navigator appVersion</h3> <p id="demo"></p> <button onclick="browserVersion()"> Return Browser varsion </button> <script> function browserVersion(){ var v = "Version: " + navigator.appVersion; document.getElementById("demo").innerHTML = v; } </script> </body> </html>
Example 2
In the following example, we are demonstrating the navigator.userAgent to find the version and details of the browser.
<!DOCTYPE html> <html lang="en"> <head> <title>Navigator</title> </head> <body> <h3>Navigator userAgent</h3> <p id="demo"></p> <button onclick="browserVersion()"> Return Browser version </button> <script> function browserVersion() { //var v = "Version: " + navigator.appVersion; var v = "Version: " + navigator.userAgent; document.getElementById("demo").innerHTML = v; } </script> </body> </html>
- Related Articles
- With JavaScript how can I find the name of the web browser, with version?
- How to detect if JavaScript is disabled in a browser?
- How to get the application name and version information of a browser in JavaScript?
- How to detect whether the browser is online or offline with JavaScript?
- How to find the R version you are using?
- How to detect which iOS version is running on the device?
- Detect the Operating System of User using JavaScript
- How to detect iOS device UDID, Name, Version, Model by programmatically?
- How can we detect duplicate labels using the Python Pandas library?
- How can I get the current Android SDK version programmatically using Kotlin?
- How to close a current tab in a browser window using JavaScript?
- How can I check the version of MySQL Server?
- How to detect the browser's format for HTML input type date
- How to know the browser language and browser platform in JavaScript?
- How to Detect if CAPS Lock is ON using JavaScript?
