Request.destination - Web APIs 编辑
The destination
read-only property of the Request
interface returns a string describing the type of content being requested. The string must be one of those found in the RequestDestination
enumerated type or the empty string, which is the default value.
The destination
is used by the user agent to, for example, help determine which set of rules to follow for CORS purposes, or how to navigate any complicated code paths that affect how specific types of request get handled.
These destinations vary substantially in how they operate. Some are data receptacles, where the received data is stored for processing later. Others are script-based, in which case the received data is delivered to a script by calling it and passing the data along. Script-based destinations include <script>
elements, as well as any of the Worklet
-based destinations (including AudioWorklet
and PaintWorklet
), and the Worker
-based destinations, including ServiceWorker
and SharedWorker
.
Syntax
var destination = request.destination;
Value
A string from the RequestDestination
enumerated type which indicates the type of content the request is asking for. This type is much broader than the usual document type values (such as "document"
or "manifest"
), and may include contextual cues such as "image"
or "worker"
or "audioworklet"
.
Example
In the following snippet, we create a new request using the Request()
constructor (for an image file in the same directory as the script), then save the request's destination:
var myRequest = new Request('flowers.jpg');
var myDestination = myRequest.destination; // returns the empty string by default
Specifications
Specification | Status | Comment |
---|---|---|
Fetch The definition of 'destination' in that specification. | Living Standard | Initial definition |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论