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 Device Screen Width and Height using javaScript
- How to Print from JavaScript HTML using window.print
- Send Extra Data with Ajax Get or Post Request
- How to get UTC (GMT) time using JavaScript
- How to detect Browser and Operating System Name and Version using JavaScript
- Fix: Error: error:0308010C:digital envelope routines::unsupported NodeJs/Vue/React
- How to send email from JavaScript HTML using mailto
- Remove items from JavaScript array
- JavaScript : Get current page address
- Add Animated Scrolling to Html Page Title Script
- [javaScript] Convert text case to lowercase
- JavaScript date in yyyy-MM-dd format
- Power of Print Statements in JavaScript: A Comprehensive Guide
- Submit html form on dropdown menu value selection or change using javascript
- Write javaScript code in Swedish using FikaScript
- Javascript convert text case from uppercase to lowercase
- Excel Fix: SECURITY RISK Microsoft has blocked macros from running because the source of this file is untrusted.
- JavaScript: Count Words in a String
- Meaning of javascript:void(0) explained with example
- JavaScript: Generate Random Numbers between 1 and 3
- npm WARN saveError ENOENT: no such file or directory, open /mnt/c/package.json
- How to get current URL Location using Javascript HTML
- Fix: SyntaxError: The requested module does not provide an export named default
- Fix: Error: Cannot find module /node-examples/init
- JavaScript: Check if variable is a number
More Posts:
- How to Open Finder using Mac Terminal - MacOS
- Android Studio emulator/Device logCat logs not displayed - Android-Studio
- How to embed web page in SharePoint - SharePoint
- How to know the Safari Version on Mac - MacOS
- Convert Java Array to ArrayList Code Example - Java
- How to show End of Line Characters in File using Notepad++ - NotepadPlusPlus
- The selected device is incompatible : Android Studio - Android-Studio
- Bash Command to Find String in a File - Bash