destination 只读特性在 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.

destination is used by the 用户代理 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 simply 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 .

句法

var destination = request.destination;
					

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" .

范例

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
					

规范

规范 状态 注释
Fetch
The definition of 'destination' in that specification.
实时标准 初始定义

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
destination Chrome 65 Edge 14 Firefox 61 IE No Opera 52 Safari 10.1 WebView Android 65 Chrome Android 65 Firefox Android 61 Opera Android 47 Safari iOS 10.3 Samsung Internet Android 9.0

图例

完整支持

完整支持

不支持

不支持

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

另请参阅

元数据

  • 最后修改: