We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

这篇翻译不完整。请帮忙从英语翻译这篇文章

这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。

Request 接口的 mode 只读属性包含请求的模式 (e.g., cors, no-cors, cors-with-forced-preflight, same-origin, or navigate.) 这用于确定跨域请求是否导致有效的响应,以及响应的哪些属性是可读的:

  • same-origin — 如果使用此模式向另外一个源发送请求,显而易见,结果会是一个错误。你可以设置该模式以确保请求总是向当前的源发起的。
  • no-cors — 保证其对应的方法只有HEAD,GET或POST方法 。即使ServiceWorkers 拦截了这个请求,除了simple header之外不会添加或覆盖任意其他header, 另外JavaScript不会读取Response的任何属性 . 这样将会确保ServiceWorkers不会影响Web语义(semantics of the Web), 同时保证了在跨域时不会发生安全和隐私泄露的问题.
  • cors — 允许跨域请求,例如访问第三方供应商提供的各种API。 These are expected to adhere to the CORS protocol. Only a limited set of headers are exposed in the Response, but the body is readable.
  • navigate — 支持导航的一个模式。 The navigate value is intended to be used only by HTML navigation. A navigate request is created only while navigating between documents.

Syntax

var myMode = request.mode;

Value

A RequestMode value.

Example

In the following snippet, we create a new request using the Request.Request() constructor (for an image file in the same directory as the script), then save the request mode in a variable:

var myRequest = new Request('flowers.jpg');
var myMode = myRequest.mode; // returns "cors" by default

Specifications

Specification Status Comment
Fetch
mode
Living Standard Initial definition

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 42.0 (Yes) 39 (39) 未实现

29
28[1]

未实现
navigate mode 49.0 ? 46 (46) 未实现 ? 未实现
Feature Android Android Webview Edge Firefox Mobile (Gecko) Firefox OS (Gecko) IE Phone Opera Mobile Safari Mobile Chrome for Android
Basic support 未实现 49.0 (Yes) 未实现 未实现 未实现 未实现 未实现 49.0
navigate mode 未实现 未实现 ? 未实现 未实现 未实现 未实现 未实现 49.0

See also

文档标签和贡献者

标签: 
此页面的贡献者: johnlin0207, FLYSLOW, xgqfrms-GitHub
最后编辑者: johnlin0207,