草案
此页面不完整。
The crossorigin attribute, valid on the
<audio>
,
<img>
,
<link>
,
<script>
,和
<video>
elements, provides support for
CORS
, defining how the element handles crossorigin requests, thereby enabling the configuration of the CORS requests for the element's fetched data. Depending on the element, the attribute can be a CORS settings attribute.
crossorigin
content attribute on media elements is a CORS settings attribute.
These attributes are enumerated, and have the following possible values:
| 关键词 | 描述 |
anonymous
|
CORS requests for this element will have the credentials flag set to 'same-origin'. |
use-credentials
|
CORS requests for this element will have the credentials flag set to 'include'. |
""
|
Setting the attribute name to an empty value, like
crossorigin
or
crossorigin=""
, is the same as
anonymous
.
|
By default (that is, when the attribute is not specified), CORS is not used at all. The "anonymous" keyword means that there will be no exchange of user credentials via cookies, client-side SSL certificates or HTTP authentication as described in the Terminology section of the CORS specification , unless it is in the same origin.
An invalid keyword and an empty string will be handled as the
anonymous
关键词。
Prior to Firefox 83 the
crossorigin
attribute was not supported for
rel="icon"
there is also
an open issue for Chrome
.
You can use the following
<script>
element to tell a browser to execute the
https://example.com/example-framework.js
script without sending user-credentials.
<script src="https://example.com/example-framework.js" crossorigin="anonymous"></script>
use-credentials
value must be used when fetching a
manifest
that requires credentials, even if the file is from the same origin.
<link rel="manifest" href="/app.webmanifest" crossorigin="use-credentials">
| 规范 | 状态 | 注释 |
|---|---|---|
|
HTML 实时标准
The definition of 'CORS settings attributes' in that specification. |
实时标准 | |
|
HTML 实时标准
The definition of 'crossorigin' in that specification. |
实时标准 |
The compatibility table in 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 上的兼容性数据| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
crossorigin
|
Chrome 完整支持 30 | Edge 完整支持 ≤18 | Firefox 完整支持 13 | IE 不支持 No | Opera 完整支持 12 |
Safari
完整支持
Yes
注意事项
|
WebView Android 完整支持 Yes | Chrome Android 完整支持 Yes | Firefox Android 完整支持 14 | Opera Android ? | Safari iOS ? | Samsung Internet Android 完整支持 Yes |
完整支持
不支持
兼容性未知
见实现注意事项。
The compatibility table in 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 上的兼容性数据| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
crossorigin
|
Chrome ? | Edge 完整支持 ≤18 | Firefox 完整支持 12 | IE ? | Opera ? | Safari ? | WebView Android ? | Chrome Android ? | Firefox Android 完整支持 14 | Opera Android ? | Safari iOS ? | Samsung Internet Android ? |
完整支持
兼容性未知
The compatibility table in 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 上的兼容性数据| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
crossorigin
|
Chrome 完整支持 25 | Edge 完整支持 79 | Firefox 完整支持 18 | IE 不支持 No | Opera 完整支持 15 | Safari ? | WebView Android 完整支持 37 | Chrome Android 完整支持 Yes | Firefox Android 完整支持 18 | Opera Android ? | Safari iOS ? | Samsung Internet Android 完整支持 Yes |
完整支持
不支持
兼容性未知