Is window.navigator.userAgent really going to be deprecated?

后端 未结 2 1520
忘掉有多难
忘掉有多难 2021-01-18 07:49

I just read on MDN about window.navigator.userAgent:

Deprecated This feature has been removed from the Web standards. Though some browsers may st

相关标签:
2条回答
  • 2021-01-18 08:04

    Use feature detection. If you need to use feature X, test to see if X is available.

    0 讨论(0)
  • 2021-01-18 08:19

    The deprecation notice seems to be gone now. It was removed yesterday, over a year after this question was first asked, with the following comment:

    rm deprecation marker. This is not removed from the living spec and no deprecation either. Most use cases are discouraged for quality reasons, but that's something else.

    The WHATWG Living standard hasn't deprecated this property, so that confirms that the property isn't going away. Sure, it's a crapshoot and easily spoofed, but "not recommended for use" is not the same as "deprecated". As you note, too many authors and organizations depend on this property for it to be simply specced out of existence and removed from implementations.

    Perhaps confusion over the meaning of the word "deprecated" is what resulted in the deprecation notice in the first place. The article itself is still incorrectly tagged "Deprecated", by the way.

    Note that Mozilla is not responsible for contributions to the MDN docs. The community is. And as with any other community-curated, unofficial knowledge base (including this very site), don't treat its information as gospel, always cross-reference, etc (as you have done here).

    0 讨论(0)
提交回复
热议问题