大网数据广告活动
Web 标准与前端开发

Request: destination property

· 52CE 我爱测

The **`destination`** read-only property of the **Request** interface returns a string describing the type of content being requested.

Fetch API

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 the audio, audioworklet, document, embed, fencedframe, font, frame, iframe, image, json, manifest, object, paintworklet, report, script, sharedworker, speculationrules, style, text, track, video, worker or xslt strings, 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 subclasses like AudioWorklet), and the Worker-based destinations, including ServiceWorker and SharedWorker.

Value

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

Possible values are:

  • ""

    • : The empty string is the default value, and is used for destinations that do not have their own value. This is the value when requests are made using the following APIs (among others):
      • <a ping>
      • <area ping>
      • Cache
      • EventSource
      • Window/fetch
      • navigator.sendBeacon()
      • WebSocket
      • XMLHttpRequest
  • "audio"

    • : The target is audio data.
  • "audioworklet"

    • : The target is data being fetched for use by an audio worklet.
  • "document"

    • : The target is a document (HTML or XML).
  • "embed"

    • : The target is embedded content.
  • "fencedframe"

  • "font"

    • : The target is a font.
  • "image"

    • : The target is an image.
  • "json"

    • : The target is a JSON file.
  • "manifest"

    • : The target is a manifest.
  • "object"

    • : The target is an object.
  • "paintworklet"

    • : The target is a paint worklet.
  • "report"

    • : The target is a report.
  • "script"

    • : The target is a script.
  • "serviceworker"

    • : The target is a service worker.
  • "sharedworker"

    • : The target is a shared worker.
  • "speculationrules"

  • "style"

    • : The target is a style
  • "text"

    • : The target is a text file.
  • "track"

    • : The target is an HTML track.
  • "video"

    • : The target is video data.
  • "worker"

    • : The target is a worker.
  • "xslt"

    • : The target is an XSLT transform.

Examples

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's destination:

const myRequest = new Request("flowers.jpg");
const myDestination = myRequest.destination; // returns the empty string by default

Specifications

Browser compatibility

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。