admin管理员组文章数量:1332638
I am running macOS Monterey (12.2) with Safari 15.3. I am trying to use JavaScript in Safari (or Chrome) to programmatically determine the version of macOS installed.
When I run the following mand:
var nAgt = navigator.userAgent;
I get the following results:
Safari
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15
Google Chrome
Mozilla/5.0 (Macintosh; Intel Mac OS X10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36
Why am I seeing 10_15_7? Should I not be seeing 12_2 somewhere?
I am running macOS Monterey (12.2) with Safari 15.3. I am trying to use JavaScript in Safari (or Chrome) to programmatically determine the version of macOS installed.
When I run the following mand:
var nAgt = navigator.userAgent;
I get the following results:
Safari
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15
Google Chrome
Mozilla/5.0 (Macintosh; Intel Mac OS X10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36
Why am I seeing 10_15_7? Should I not be seeing 12_2 somewhere?
Share Improve this question asked Jan 10, 2022 at 16:44 HirsuteJimHirsuteJim 6766 silver badges15 bronze badges 1- 1 bugs.webkit/show_bug.cgi?id=216593 – Quentin Commented Jan 10, 2022 at 16:45
2 Answers
Reset to default 5User agent string is no longer reliable in future versions of Mac OS and Windows (11). You should look into client hints API for javascript. Some references for context and the future solution:
https://www.otsukare.info/2021/02/15/capping-macos-user-agent
https://help.duo./s/article/6627?language=en_US
https://web.dev/user-agent-client-hints/
https://browserleaks./client-hints
The new API doesn't work for all browsers yet. So until the world catches up, the detection for new OSes is best effort.
Thank you to @Quentin ... IF I understand correctly, It appears that one can no longer get accurate reporting of the newer macOS systems via the UserAgent.
It seems much of the world simply assumed that it would be
macOS 10.xx
forever and therefore many sites could not handle amacOS 11.xx
or amacOS 12.xx
response.There also appears to be a desire to hide underlying details of the OS for those who might use it for nefarious "fingerprinting purposes".
本文标签: How to Detect macOS Big Sur andor Monterey in JavaScriptStack Overflow
版权声明:本文标题:How to Detect macOS Big Sur andor Monterey in JavaScript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742272171a2444511.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论