DeprecatedThis feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
The deprecated context
read-only property of the Request
interface contains the context of the Request (e.g., audio
, image
, iframe
). This defines what sort of resource is being fetched. This has been replaced by the destination
property.
The context of a request is only relevant in the ServiceWorker API; a service worker can make decisions based on whether the URL is for an image, or an embeddable object such as a <video>
, iframe
, etc.
Note: You can find a full list of the different available contexts including associated context frame types, CSP directives, and platform feature examples in the Fetch spec request context section.
Syntax
var myContext = request.context;
Value
A RequestContext
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 context in a variable:
var myRequest = new Request('flowers.jpg');
var myContext = myRequest.context; // returns the empty string by default
Browser compatibility
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.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Chrome
No support 42 — 46 |
Edge
? |
Firefox No support 39 — 42 No support 39 — 42 Notes' see bug 1188062 for more information. |
IE
No support No |
Opera
No support 28 — 29 |
Safari
No support No |
WebView Android
No support 42 — 46 |
Chrome Android
No support 42 — 46 |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
No support 4.0 — 5.0 |
Legend
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- Experimental. Expect behavior to change in the future.'
- Experimental. Expect behavior to change in the future.
- Non-standard. Expect poor cross-browser support.'
- Non-standard. Expect poor cross-browser support.
- Deprecated. Not for use in new websites.'
- Deprecated. Not for use in new websites.
- See implementation notes.'
- See implementation notes.
See also
Request.context by Mozilla Contributors is licensed under CC-BY-SA 2.5.