How to find the operating system version using JavaScript?

后端 未结 13 1097
滥情空心
滥情空心 2020-11-22 04:32

How can I find the OS name and OS version using JavaScript?

13条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 05:05

    You can find the OS name and version in the navigator object, as others have answered. The standard, cross-browser place to find this information is in the navigator.userAgent property. However, user agent strings vary widely by OS and browser.

    So, I created a script to encapsulate this logic and report on the most common OSes and browsers in a familiar way, like http://www.whatsmybrowser.org.

    I open-sourced the script and uploaded it to github, https://github.com/keithws/browser-report. Pull requests are welcome!

提交回复
热议问题