-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
117 lines (97 loc) · 3.87 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
title: "Request: destination property"
short-title: destination
slug: Web/API/Request/destination
page-type: web-api-instance-property
browser-compat: api.Request.destination
---
{{APIRef("Fetch API")}}
The **`destination`** read-only
property of the **{{domxref("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`,
`style`, `track`, `video`, `worker`
or `xslt` strings, or the empty string, which is the default value.
The `destination` is used by the {{Glossary("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 {{HTMLElement("script")}} elements, as well as
any of the {{domxref("Worklet")}}-based destinations
(including subclasses like {{domxref("AudioWorklet")}}), and the
{{domxref("Worker")}}-based destinations, including {{domxref("ServiceWorker")}}
and {{domxref("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>`](/en-US/docs/Web/HTML/Element/a#ping)
- [`<area ping>`](/en-US/docs/Web/HTML/Element/area#ping)
- {{domxref("Cache")}}
- {{domxref("EventSource")}}
- {{domxref("fetch()")}}
- {{domxref("navigator.sendBeacon()")}}
- {{domxref("WebSocket")}}
- {{domxref("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"`
- : The target is a [fenced frame](/en-US/docs/Web/API/Fenced_frame_API).
- `"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.
- `"style"`
- : The target is a style
- `"track"`
- : The target is an HTML {{HTMLElement("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
{{domxref("Request.Request", "Request()")}} constructor (for an image file in the same
directory as the script), then save the request's destination:
```js
const myRequest = new Request("flowers.jpg");
const myDestination = myRequest.destination; // returns the empty string by default
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [ServiceWorker API](/en-US/docs/Web/API/Service_Worker_API)
- [HTTP access control (CORS)](/en-US/docs/Web/HTTP/CORS)
- [HTTP](/en-US/docs/Web/HTTP)