如果不推荐使用window.navigator.userAgent,我应该使用什么呢? [英] If window.navigator.userAgent is deprecated, what should I use instead?

查看:107
本文介绍了如果不推荐使用window.navigator.userAgent,我应该使用什么呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MDN文档说明了window.navigator .userAgent已弃用,不应使用。如果我想收集用户浏览器和操作系统数据进行分析(而不是功能检测),我应该使用什么呢?

The MDN documentation says that window.navigator.userAgent is deprecated and should not be used. If I want to collect the users browser and os data for analytics (not feature detection), what should I use instead?

推荐答案

用户代理字符串变得毫无意义且非常不可靠。

The user agent string is becoming meaningless and extremely unreliable.

您不应使用用户代理字符串,而应使用功能检测。如果您需要使用功能X,请测试X是否可用。

You should not use user agent string, rather you should use feature detection. If you need to use feature X, test to see if X is available.

但是直接回答您的问题,没有JS替代方案。

But to also answer your question directly, there is no JS alternative.

这篇关于如果不推荐使用window.navigator.userAgent,我应该使用什么呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆