How to detect if user is using Mac or Windows on website

detection, operating-system, web

Solution

In Javascript:

http://www.quirksmode.org/js/detect.html

No method is perfect, because the user can always spoof the user-agent.

I would recommend that:

1) Auto-redirect to a page with the link, or auto update the link on a page with text saying "Download for Mac" or "Download for Windows", so that the user knows what they are getting before they click.

2) Still give the user the option of downloading the other version, in case your detection does not work in their case, or if they want to download on a remote machine, and transfer it to a different machine later.

Problem

What's the standard, most reliable way of doing this? I need to redirect a user to download the Mac version or the Windows version of my software when they click "Download" on my website.

Original source