I am looking for a way to detect the OS for a downloads page using jQuery or Javascript to recommend specific files for Mac vs Windows. I was hoping to do it without adding another plugin to my page.
Try: var os = navigator. platform; Then handle the os variable accordingly for your result.
To detect the operating system on the client machine, one can simply use navigator. appVersion or navigator. userAgent property. The Navigator appVersion property is a read-only property and it returns a string which represents the version information of the browser.
Try:
var os = navigator.platform;
Then handle the os variable accordingly for your result.
You can also loop through each object of the navigator
object to help get you more familiarized with the objects:
<script type="text/javascript"> for(var i in navigator){ console.log(i+"="+navigator[i]+'<br>'); } </script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With