In HTML5, some HTML elements which provide support for CORS, such as <img>
, <video>
or <script>
, have a crossorigin
attribute (crossOrigin
property), which lets you configure the CORS requests for the element's fetched data. These attributes are enumerated, and have the following possible values:
Keyword | Description |
---|---|
anonymous | CORS requests for this element will not have the credentials flag set. |
use-credentials | CORS requests for this element will have the credentials flag set; this means the request will provide credentials. |
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.
An invalid keyword and an empty string will be handled as the anonymous
keyword.
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>
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'CORS settings attributes' in that specification. | Living Standard | |
HTML Living Standard The definition of 'crossorigin' in that specification. | Living Standard |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 30 | Yes | 13 | No | 12 | Yes
|
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes | Yes | ? | 14 | ? | ? | Yes |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | ? | Yes | 12 | ? | ? | ? |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | ? | ? | Yes | 14 | ? | ? | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes