How can I find the OS name and OS version using JavaScript?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
I fork @Ludwig code and remove necessity of
swfobject
.I just use swfobject code for detect flash version.
I started to write a Script to read OS and browser version that can be tested on Fiddle. Feel free to use and extend.
@Ludwig 's solution was brilliant. A couple of fixes (which didn't have to do with operating system, and I couldn't place as a comment on his original posting because this is too long):
Here they are:
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 thenavigator.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!
I can't comment on @Ian Ippolito answer (because I would have if I had the rep) but according to the document his comment linked, I'm fairly certain you can find the Chrome version for IOS. https://developer.chrome.com/multidevice/user-agent?hl=ja lists the UA as: Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1
So this should work:
Haven't been able to test (otherwise I would have improved his answer) it to make sure since my iPad is at home and I'm at work, but I thought I'd put it out there.