From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../web/api/navigatorid/appcodename/index.html | 36 +++++++ files/zh-cn/web/api/navigatorid/appname/index.html | 37 +++++++ .../web/api/navigatorid/appversion/index.html | 42 ++++++++ files/zh-cn/web/api/navigatorid/index.html | 120 +++++++++++++++++++++ .../zh-cn/web/api/navigatorid/platform/index.html | 35 ++++++ files/zh-cn/web/api/navigatorid/product/index.html | 34 ++++++ .../zh-cn/web/api/navigatorid/useragent/index.html | 79 ++++++++++++++ 7 files changed, 383 insertions(+) create mode 100644 files/zh-cn/web/api/navigatorid/appcodename/index.html create mode 100644 files/zh-cn/web/api/navigatorid/appname/index.html create mode 100644 files/zh-cn/web/api/navigatorid/appversion/index.html create mode 100644 files/zh-cn/web/api/navigatorid/index.html create mode 100644 files/zh-cn/web/api/navigatorid/platform/index.html create mode 100644 files/zh-cn/web/api/navigatorid/product/index.html create mode 100644 files/zh-cn/web/api/navigatorid/useragent/index.html (limited to 'files/zh-cn/web/api/navigatorid') diff --git a/files/zh-cn/web/api/navigatorid/appcodename/index.html b/files/zh-cn/web/api/navigatorid/appcodename/index.html new file mode 100644 index 0000000000..5f5f0e91da --- /dev/null +++ b/files/zh-cn/web/api/navigatorid/appcodename/index.html @@ -0,0 +1,36 @@ +--- +title: NavigatorID.appCodeName +slug: Web/API/NavigatorID/appCodeName +translation_of: Web/API/NavigatorID/appCodeName +--- +

{{ ApiRef() }}

+ +

概述

+ +

返回所使用浏览器的内部名称.

+ +

语法

+ +
codeName = window.navigator.appCodeName
+
+ +

参数

+ + + +

例子

+ +
dump(window.navigator.appCodeName);
+
+ +

笔记

+ +

Mozilla, Netscape 6, 和 IE5 的内部名称都是 "Mozilla".

+ +

规范

+ +

{{ DOM0() }}

+ +

{{ languages( { "en": "en/DOM/window.navigator.appCodeName","ja": "ja/DOM/window.navigator.appCodeName", "pl": "pl/DOM/window.navigator.appCodeName" } ) }}

diff --git a/files/zh-cn/web/api/navigatorid/appname/index.html b/files/zh-cn/web/api/navigatorid/appname/index.html new file mode 100644 index 0000000000..389e0b367b --- /dev/null +++ b/files/zh-cn/web/api/navigatorid/appname/index.html @@ -0,0 +1,37 @@ +--- +title: NavigatorID.appName +slug: Web/API/NavigatorID/appName +translation_of: Web/API/NavigatorID/appName +--- +

{{ ApiRef() }}

+ +

概述

+ +

返回所使用浏览器的名称。由于兼容性问题,HTML5 规范允许该属性返回 "Netscape" 。

+ +
注意:该属性并不一定能返回正确的浏览器名称。在基于 Gecko 的浏览器 (例如 Firefox)和基于 WebKit 的浏览器(例如 Chrome 和 Safari)中,返回的浏览器名称都是 "Netscape".
+ +

语法

+ +
appName = window.navigator.appName
+
+ +

返回值

+ + + +

例子

+ +
alert(window.navigator.appName);
+// 显示浏览器名称
+
+ +

规范

+ + + +

该属性起初属于 DOM Level 0 ,目前已经被添加到HTML5规范中。

diff --git a/files/zh-cn/web/api/navigatorid/appversion/index.html b/files/zh-cn/web/api/navigatorid/appversion/index.html new file mode 100644 index 0000000000..8fe576cecf --- /dev/null +++ b/files/zh-cn/web/api/navigatorid/appversion/index.html @@ -0,0 +1,42 @@ +--- +title: NavigatorID.appVersion +slug: Web/API/NavigatorID/appVersion +translation_of: Web/API/NavigatorID/appVersion +--- +

{{APIRef("HTML DOM")}}{{deprecated_header}}

+ +

概述

+ +

返回一个字符串,表示所使用浏览器的版本号。它可能只包含一个版本数字,如 "5.0",还可能包含一些其他的相关信息。由于兼容性问题,HTML5规范允许该属性返回 "4.0"。

+ +
注意:该属性并不一定能返回正确的浏览器版本号。在基于 Gecko 的浏览器 (例如 Firefox)和基于 WebKit 的浏览器(例如 Chrome 和 Safari)中,返回的浏览器版本号都是 "5.0",后跟一些操作系统与语言信息,比如 "5.0 (Windows; zh-CN)"。在Opera 10及以上版本,该属性的返回值也不是实际的浏览器版本号。
+ +

语法

+ +
ver = window.navigator.appVersion
+
+ +

返回值

+ + + +

例子

+ +
alert("你的浏览器版本为" + navigator.appVersion);
+
+ +

备注

+ +

window.navigator.userAgent 也包含一些浏览器的版本信息(比如:"Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.2) Gecko/20010725 Netscape 6/6.1"),但是你应该知道,修改浏览器的userAgent字符串以及伪造它成为其他的浏览器、其他的操作系统等等是非常容易的。而且,就算不伪造,浏览器提供商也不会保证这些数据就是准确的。

+ +

window.navigator.appVersionwindow.navigator.appNamewindow.navigator.userAgent 等属性都被用来编写一些"浏览器检测"的相关代码:脚本会尝试根据检测出的浏览器类型来相印的调整页面显示。种情况下,用户可以伪造相关的浏览器信息来查看一些本来不允许自己所使用的浏览器或平台查看的页面。

+ +

规范

+ + + +

该属性最初属于 DOM Level 0,目前已经被添加到 HTML5 规范中。

diff --git a/files/zh-cn/web/api/navigatorid/index.html b/files/zh-cn/web/api/navigatorid/index.html new file mode 100644 index 0000000000..5fab09ada5 --- /dev/null +++ b/files/zh-cn/web/api/navigatorid/index.html @@ -0,0 +1,120 @@ +--- +title: NavigatorID +slug: Web/API/NavigatorID +translation_of: Web/API/NavigatorID +--- +

{{APIRef("HTML DOM")}}

+ +

NavigatorID 接口包含浏览器识别相关的方法和属性。

+ +

没有一个 NavigatorID 类型的对象,他是其他接口,如 {{domxref("Navigator")}} 或 {{domxref("WorkerNavigator")}} 实现了该接口。

+ +

属性

+ +

NavigatorID 接口没有继承任何属性。

+ +
+
{{domxref("NavigatorID.appCodeName")}} {{readonlyInline}}{{experimental_inline}}
+
任何浏览器中,总是返回 'Gecko'。该属性仅仅是为了保持兼容性。
+
{{domxref("NavigatorID.appName")}} {{readonlyInline}}
+
返回浏览器的官方名称。不要指望该属性返回正确的值。
+
{{domxref("NavigatorID.appVersion")}} {{readonlyInline}}
+
返回一个字符串,表示浏览器的版本。不要指望该属性返回正确的值。
+
{{domxref("NavigatorID.platform")}} {{readonlyInline}}
+
返回一个字符串,表示浏览器的所在系统平台。
+
{{domxref("NavigatorID.product")}} {{readonlyInline}}
+
返回当前浏览器的产品名称(如,"Gecko")。
+
{{domxref("NavigatorID.userAgent")}} {{readonlyInline}}
+
返回当前浏览器的用户代理字符串(user agent string)。
+
+ +

方法

+ +

NavigatorID 接口没有继承任何方法。

+ +
+
{{domxref("NavigatorID.taintEnabled()")}} {{deprecated_inline()}} {{experimental_inline}}
+
总是返回 false。JavaScript taint/untaint 函数在 JavaScript 1.2 中被移除了。该方法只是为了兼容性。
+
+ +

规范

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#navigatorid', 'NavigatorID')}}{{Spec2('HTML WHATWG')}}Added the appCodeName property and the taintEnabled() method,  for compatibility purpose.
{{SpecName('HTML5 W3C', '#navigatorid', 'NavigatorID')}}{{Spec2('HTML5 W3C')}}Initial specification.
+ +

浏览器兼容性

+ +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +

相关链接

+ + diff --git a/files/zh-cn/web/api/navigatorid/platform/index.html b/files/zh-cn/web/api/navigatorid/platform/index.html new file mode 100644 index 0000000000..a80d295ccb --- /dev/null +++ b/files/zh-cn/web/api/navigatorid/platform/index.html @@ -0,0 +1,35 @@ +--- +title: NavigatorID.platform +slug: Web/API/NavigatorID/platform +translation_of: Web/API/NavigatorID/platform +--- +

{{ ApiRef() }}

+ +

概述

+ +

返回一个字符串,表示浏览器所在的系统平台类型.

+ +

语法

+ +
platform = navigator.platform
+
+ +

platform 可能是: "Win32", "Linux i686", "MacPPC", "MacIntel", 等.

+ +

例子

+ +
alert(navigator.platform);
+ +

备注

+ +

在普通网页中,如果about:config中存在general.platform.override项,则该属性的值会返回about:config中general.platform.override项的值. 在特权代码中 (chrome上下文或者拥有"UniversalBrowserRead"特权的网页中),返回的还是真实的平台类型.(译者注:语句:netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead ")用来激活所在网页的UniversalBrowserRead特权.)

+ +

规范

+ + + +

该属性由DOM Level 0提出, 目前已经被添加到HTML5规范中.

+ +

{{ languages( {"ja": "ja/DOM/window.navigator.platform", "en": "en/DOM/window.navigator.platform", "pl": "pl/DOM/window.navigator.platform" } ) }}

diff --git a/files/zh-cn/web/api/navigatorid/product/index.html b/files/zh-cn/web/api/navigatorid/product/index.html new file mode 100644 index 0000000000..0c660198d1 --- /dev/null +++ b/files/zh-cn/web/api/navigatorid/product/index.html @@ -0,0 +1,34 @@ +--- +title: NavigatorID.product +slug: Web/API/NavigatorID/product +translation_of: Web/API/NavigatorID/product +--- +
+ {{ApiRef}}
+

概述

+

该属性返回当前浏览器的产品名称。

+
+ 注意:该属性不一定返回一个真实的产品名称。Gecko 和 WebKit 浏览器返回 "Gecko" 作为该属性的值。
+

语法

+
productName = window.navigator.product
+
+ +

例子

+
<script>
+function prod() {
+  dt = document.getElementById("d");
+  dt.innerHTML = window.navigator.product;
+}
+</script>
+
+<button onclick="prod();">product</button>
+<div id="d"> </div>
+<!-- 返回 "Gecko" -->
+
+

备注

+

在基于 Gecko 的浏览器中,product 为完整的用户代理(user agent)字符串中紧跟着平台(platform)后的部分。例如,在 Netscape 6.1 的用户代理中,product 是 "Gecko",完整的代理字符串是:Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.2) Gecko/20010725 Netscape6/6.1

+

在基于 WebKit 的浏览器中,product 仍然返回 "Gecko",即使完整用户代理字符串中平台(platform)后紧跟着:(KHTML, like Gecko)

+

规范

+

{{dom0}}

diff --git a/files/zh-cn/web/api/navigatorid/useragent/index.html b/files/zh-cn/web/api/navigatorid/useragent/index.html new file mode 100644 index 0000000000..b5f2a23ab0 --- /dev/null +++ b/files/zh-cn/web/api/navigatorid/useragent/index.html @@ -0,0 +1,79 @@ +--- +title: NavigatorID.userAgent +slug: Web/API/NavigatorID/userAgent +translation_of: Web/API/NavigatorID/userAgent +--- +
{{ApiRef("HTML DOM")}}
+ +

NavigatorID.userAgent 只读属性返回当前浏览器的 user agent 字符串。

+ +
+

这一规范要求浏览器通过这一属性提供尽可能少的信息。不要假定同一浏览器的这一属性值会在未来的版本中保持不变。尽量不要使用这一属性,或者仅仅在现有和更早的版本中使用。较新的浏览器可能开始使用相同或近似的 UA,对于早期的浏览器而言:你不能确保该浏览器是其 NavigatorID.userAgent 属性所宣称的浏览器。

+ +

另外要记住,用户可以修改浏览器的此属性(UA 欺骗).

+
+ +

基于 user agent 字符串来识别浏览器是不可靠的,不推荐使用,因为 user agent 字符串是用户可配置的。例如:

+ + + +

语法

+ +
var ua = navigator.userAgent;
+
+ +

+ +

{{domxref("DOMString")}} 规定了浏览器提供给 {{Glossary("HTTP")}} headers 和其响应,以及其他与{{domxref("Navigator")}} 相关的方法的完整用户代理属性 。

+ +

用户代理属性由几个信息段组成一个整齐的结构,每个信息段都取值于其他 {{domxref("Navigator")}} 属性,这些属性也可以是用户设置的。基于 Gecko 内核的浏览器的 UA 遵守下列通用结构规范。

+ +
userAgent = appCodeName/appVersion number (Platform; Security; OS-or-CPU;
+Localization; rv: revision-version-number) product/productSub
+Application-Name Application-Name-version
+
+ +

例子

+ +
alert(window.navigator.userAgent)
+// alerts "Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.2) Gecko/20010725 Netscape6/6.1"
+
+ + + +

规范

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-navigator-useragent', 'NavigatorID.userAgent')}}{{Spec2('HTML WHATWG')}}Initial definition
+ +

浏览器兼容性

+ + + +

{{Compat("api.NavigatorID.userAgent")}}

+ +

更多

+ + -- cgit v1.2.3-54-g00ecf