---
title: "Discussion on \"Detect Operating System using Javascript\" | Hashnode"
description: "Discussion on \"Detect Operating System using Javascript\". Let's see how we can detect the Operating System on which the website is accessed using Javascript.\nSample Code:\n<a>Host:</a>\n<a id=\"detectos\"></a>\n<script> \n        HTMLDocument.prototype.e = document.getElementById; \n        var exdo = document.e(\"..."
url: "https://hashnode.com/posts/detect-operating-system-using-javascript/5f7704347d160d41227d6869"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Detect Operating System using Javascript](https://sarthakroy2002.hashnode.dev/detect-operating-system-using-javascript?utm_source=hashnode&utm_medium=feed)

Let's see how we can detect the Operating System on which the website is accessed using Javascript. Sample Code: <a>Host:</a> <a id="detectos"></a> <script> HTMLDocument.prototype.e = document.getElementById; var exdo = document.e("...

Oct 2, 2020 · 2 min read · sarthakroy2002.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#javascript-framework](https://hashnode.com/tag/javascript-framework)
-   [#javascript-library](https://hashnode.com/tag/javascript-library)
-   [#html5](https://hashnode.com/tag/html5)
-   [#html](https://hashnode.com/tag/html)

## Written by

[Sarthak Roy](https://hashnode.com/@sarthakroy2002)

@sarthakroy2002 · Kolkata, India

  
[View profile](https://hashnode.com/@sarthakroy2002)

Coding for Life

A 21-year Tech Enthusiast from Kolkata. MCA Postrgrad Student, Vellore Institute of Technology, Chennai, India. Opensource🤎

## Responses 3

Markdown supported · ⌘↵ to post

[YAKSH BARIYA](https://hashnode.com/@CodingThunder)

[Oct 4, 2020](https://hashnode.com/posts/detect-operating-system-using-javascript/5f7704347d160d41227d6869/comment/5f79869d7d160d41227d8047)

This does not work properly on Android devices. It showed me Linux instead of Android

[YAKSH BARIYA](https://hashnode.com/@CodingThunder)

[Oct 6, 2020](https://hashnode.com/posts/detect-operating-system-using-javascript/5f7704347d160d41227d6869/comment/5f79869d7d160d41227d8047#reply-5f7bf37fe93896601dd29297)

Is there any way to check if the device is an Android device?? [Sarthak Roy](https://hashnode.com/@sarthakroy2002)

[Sarthak Roy](https://hashnode.com/@sarthakroy2002)

[Oct 9, 2020](https://hashnode.com/posts/detect-operating-system-using-javascript/5f7704347d160d41227d6869/comment/5f79869d7d160d41227d8047#reply-5f7ff249b8638504a7c12555)

I dont know that brother [YAKSH BARIYA](https://hashnode.com/@CodingThunder)

[SAMBIT CHAKRABORTY](https://hashnode.com/@SambitHashnodeChak)

[Oct 13, 2022](https://hashnode.com/posts/detect-operating-system-using-javascript/5f7704347d160d41227d6869/comment/5f79869d7d160d41227d8047#reply-63482a976461073d09df8336)

the basic kernel of android is nothing but a linux. We can say that Android is modified Linux, for providing the support for mobile devices. So, when you're detecting for android, it'll show that it's Linux.

[Denny Trebbin](https://hashnode.com/@nerdalytics)

[Oct 2, 2020](https://hashnode.com/posts/detect-operating-system-using-javascript/5f7704347d160d41227d6869/comment/5f774ccf9c3b6e4101215e0d)

The solution is attractive but not bulletproof. Changing the `UserAgent` in Safari is enough to trick the script into thinking I'm on Windows.

`platform` and `vendor` offer more details than just `appVersion` alone.

And checking `appVersion` to contain "Mac" doesn't identify iPhone, iPad, or other Apple devices because "Mac" is always included in the `appVersion` on every Apple product.

![Windows detected after changing UserAgent](https://cdn.hashnode.com/res/hashnode/image/upload/v1601654227028/EBf5vi54Z.png)

![MacOS detected despite using iPhone UserAgent](https://cdn.hashnode.com/res/hashnode/image/upload/v1601654265328/Z0bUIncC6.png)

But it's a good start to improve upon :-)

[Sarthak Roy](https://hashnode.com/@sarthakroy2002)

[Oct 3, 2020](https://hashnode.com/posts/detect-operating-system-using-javascript/5f7704347d160d41227d6869/comment/5f774ccf9c3b6e4101215e0d#reply-5f7804929c3b6e41012162e7)

Thanks...I have fixed it.....

[Dwaipayan Dasgupta](https://hashnode.com/@DwaipayanDDG)

[Oct 2, 2020](https://hashnode.com/posts/detect-operating-system-using-javascript/5f7704347d160d41227d6869/comment/5f773e687d160d41227d6bcf)

Excellent one👍
