为什么JavaScript navigator.appName为Safari,Firefox和Chrome返回Netscape? [英] Why does JavaScript navigator.appName return Netscape for Safari, Firefox and Chrome?

查看:326
本文介绍了为什么JavaScript navigator.appName为Safari,Firefox和Chrome返回Netscape?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么 navigator.appName 为Safari,Firefox和Chrome返回Netscape?

Why does navigator.appName return "Netscape" for Safari, Firefox and Chrome?

与旧浏览器Netscape有关系?可能是因为DOM0吗?

What do they have to do with the old browser Netscape? Could it be because of DOM0?

推荐答案

是的,这是兼容性问题,不要依赖。

MDN 表示:这原本是DOM Level 0的一部分,但已经包含在HTML5规范中。

Yes and that's for compatibility issues and not to be relied on.
MDN says: "This was originally part of DOM Level 0, but has been since included in the HTML5 spec."

请参阅 Mozilla 文档这里

See Mozilla documentation here.

BTW;这就是为什么这不能用于浏览器检测。 浏览器检测是一种BAD实践,您应该尽可能避免。 功能检测 。但是,如果有人坚持这个;他们应该使用 userAgent 属性。

BTW; that's why this cannot be used for browser detection. Browser detection is a BAD practice and you should always avoid it where possible. Do feature detection instead. But if anybody insists on this; they should use the userAgent property instead.

更新1 :根据兼容性更改; IE11 现在还返回Netscape navigator.appName 属性,以反映HTML5标准和匹配其他浏览器的行为。另请参阅 userAgent string 这里 ...更多功能检测这里 ...

UPDATE 1: According to Compatibility Changes; IE11 now also returns "Netscape" for navigator.appName property, to reflect the HTML5 standard and to match behavior of other browsers. Also see changes in userAgent string here... More on feature detection here...

更新2 Microsoft Edge 返回Netscape navigator.appName

UPDATE 2: Microsoft Edge also returns "Netscape" for navigator.appName.

这篇关于为什么JavaScript navigator.appName为Safari,Firefox和Chrome返回Netscape?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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