不推荐使用的Javascript OS检测技术 [英] Deprecated Javascript OS detection techniques

查看:96
本文介绍了不推荐使用的Javascript OS检测技术的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道为什么 navigator.userAgent navigator.appName navigator.appVersion navigator这样的javascript操作系统检测技术。平台正在从Web标准中删除。

I was wondering why javascript os detection techniques like navigator.userAgent, navigator.appName, navigator.appVersion and navigator.platform are in process of being dropped from web standards.

https://developer.mozilla.org/zh-CN/docs/Web/API/Navigator

如果您访问所有这些导航器道具,则可以看到

If you visit every of those navigator props, you can see

已弃用

此功能已从Web标准中删除。尽管某些浏览器可能仍支持它,但是它正在被删除。不要在新旧项目中使用它。

This feature has been removed from the Web standards. Though some browsers may still support it, it is in the process of being dropped. Do not use it in old or new projects. Pages or Web apps using it may break at any time.

所以我想知道


  1. 为什么要删除它

  2. 他们会为操作系统检测引入新的方法吗?

  3. 即使他们

在很多情况下,我们需要了解操作系统版本。

Probably there is a lot of cases where we need to know OS version.

推荐答案

在MDN上,它被错误或意外地标记为已弃用。一旦发现问题,他们便迅速纠正了该页面,但是由于它是一个确定的信息源,因此在各处仍然存在对其不推荐使用的引用。

It was incorrectly or accidentally marked as deprecated on MDN. They quickly corrected the page once they saw the problem, but since it had been a definitive source, references to it being deprecated still exist here and there.

这里是固定的对话:
https://groups.google.com/forum/#!topic/mozilla.dev.mdc/tIx2iiH2u3o

这篇关于不推荐使用的Javascript OS检测技术的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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