There are times when you need to know what browser and operating system the user is using so as to display CSS and javaScript code correctly. There are many javascript libraries that are available that lets you detect them, one of such library are detect.js released under MIT License.
detect.js file uses navigator.userAgent to detect the browser details and navigator.platform to detect operating system details.
Browsers Supported :Internet Explorer 6, 7, 8, 9,10+ Mobile
Firefox 3.6, 4, 5, 6, 7+ Mobile
Safari 3, 4, 5+ Mobile
Opera 9, 10, 11+ Mini, Mobile
Chrome, Mobile
This script is able to detect the following Operating systems :
Mac OS X
Windows
Linux
Android
iOS
Example :
<html>
<head>
<title>Detect Browser and OS details </title>
<body>
<script src="detect.js">
document.write("Browser : " + window.ui.browser);
document.write("<br/>");
document.write("Browser version : " + window.ui.version);
document.write("<br/>");
document.write("Operating System : " + window.ui.os);
document.write("<br/>");
document.write("Operating System version : " + window.ui.osversion);
document.write("<br/>");
</script>
</body>
</html>
Output Example:
Browser : Chrome
Browser version : 83.0.4103.97
Operating System : Windows
Operating System version: undefined
More Posts related to JavaScript,
- Get Current time in GMT/UTC using JavaScript
- How to get current URL Location using Javascript HTML
- Excel Fix: SECURITY RISK Microsoft has blocked macros from running because the source of this file is untrusted.
- Convert Javascript object to JSON String example
- Fix: ReferenceError: require is not defined in ES module scope [Node]
- [JavaScript] Remove all Newlines From String
- JavaScript : Get url protocol HTTP, HTTPS, FILE or FTP
- Fix: Error: error:0308010C:digital envelope routines::unsupported NodeJs/Vue/React
- Pure JavaScript Digital Clock Widget to get GMT/UTC Time Now
- Fix: npm vs code eacces permission denied unlink /usr/local/bin/code
- Power of Print Statements in JavaScript: A Comprehensive Guide
- [javaScript] Convert text case to lowercase
- JavaScript: Count Words in a String
- JavaScript date in yyyy-MM-dd format
- How to send email from JavaScript HTML using mailto
- How to get UTC (GMT) time using JavaScript
- JavaScript: Generate Random Numbers between 1 and 3
- How to get query string in JavaScript HTML location.search
- Fix: Uncaught ReferenceError: exit is not defined - Node.js REPL
- Detect if Cookies are enabled using JavaScript
- Submit html form on dropdown menu value selection or change using javascript
- Send Extra Data with Ajax Get or Post Request
- Loading previous page using html button using JavaScript
- 10 ways to Convert String to a Number in JavaScript
- JavaScript: Check if variable is a number
More Posts:
- Fix - JioCinema Something Went Wrong Please Try Again Error 8001 while streaming IPL Cricket Live - HowTos
- Android Development - How to switch between two Activities - Android
- Git Rename master branch make to main using Command - Git
- Fix java.net.ProtocolException: Invalid HTTP method - Java
- List of Special Parameters/Variables in Bash Shell Scripting - Linux
- Truncate table using Java JDBC Example - Java
- How to install Anaconda on Mac (M1/M2 Mac) - Python
- How to calculate SUM in Excel on Mac with Examples - Microsoft