草案
此页面不完整。

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 .

Example: crossorigin with the script element

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>
		

Example: Webmanifest with credentials

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.
实时标准

浏览器兼容性

<script crossorigin>

更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
crossorigin Chrome 完整支持 30 Edge 完整支持 ≤18 Firefox 完整支持 13 IE 不支持 No Opera 完整支持 12 Safari 完整支持 Yes 注意事项
完整支持 Yes 注意事项
注意事项 crossorigin attribute was implemented in WebKit in WebKit bug 81438 .
WebView Android 完整支持 Yes Chrome Android 完整支持 Yes Firefox Android 完整支持 14 Opera Android ? Safari iOS ? Samsung Internet Android 完整支持 Yes

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

见实现注意事项。

见实现注意事项。

<video crossorigin>

更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
crossorigin Chrome ? Edge 完整支持 ≤18 Firefox 完整支持 12 IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Firefox Android 完整支持 14 Opera Android ? Safari iOS ? Samsung Internet Android ?

图例

完整支持

完整支持

兼容性未知 ?

兼容性未知

更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
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

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

另请参阅

元数据

  • 最后修改:
  1. Allowing cross-origin use of images and canvas
  2. 使用 CSS 将颜色应用到 HTML 元素
  3. Block-level elements
  4. DASH Adaptive Streaming for HTML 5 Video
  5. 用于 HTML 的日期和时间格式
  6. 全局属性
    1. 全局属性
    2. accesskey
    3. autocapitalize
    4. class
    5. contenteditable
    6. contextmenu
    7. data-*
    8. dir
    9. draggable
    10. dropzone
    11. hidden
    12. id
    13. inputmode
    14. is
    15. itemid
    16. itemprop
    17. itemref
    18. itemscope
    19. itemtype
    20. lang
    21. part
    22. slot
    23. spellcheck
    24. style
    25. tabindex
    26. title
    27. translate
    28. x-ms-acceleratorkey
    29. x-ms-format-detection
  7. HTML 属性参考
    1. HTML 属性参考
    2. HTML attribute: accept
    3. HTML attribute: capture
    4. HTML attribute: crossorigin
    5. HTML attribute: max
    6. HTML attribute: maxlength
    7. HTML attribute: min
    8. HTML attribute: minlength
    9. HTML attribute: multiple
    10. HTML attribute: pattern
    11. HTML attribute: readonly
    12. HTML attribute: rel
    13. HTML attribute: required
    14. HTML attribute: size
    15. HTML attribute: step
    16. The HTML autocomplete attribute
    17. 被禁用
  8. HTML documentation index
  9. HTML 元素参考
    1. HTML 元素参考
    2. <a>: The Anchor element
    3. <abbr>: The Abbreviation element
    4. <acronym>
    5. <address>: The Contact Address element
    6. <applet>: The Embed Java Applet element
    7. <area>
    8. <article>: The Article Contents element
    9. <aside>: The Aside element
    10. <audio>: The Embed Audio element
    11. <b>: The Bring Attention To element
    12. <base>: The Document Base URL element
    13. <basefont>
    14. <bdi>: The Bidirectional Isolate element
    15. <bdo>: The Bidirectional Text Override element
    16. <bgsound>: The Background Sound element (obsolete)
    17. <big>: The Bigger Text element
    18. <blink>: The Blinking Text element (obsolete)
    19. <blockquote>: The Block Quotation element
    20. <body>: The Document Body element
    21. <br>: The Line Break element
    22. <button>: The Button element
    23. <canvas>: The Graphics Canvas element
    24. <caption>: The Table Caption element
    25. <center>: The Centered Text element (obsolete)
    26. <cite>: The Citation element
    27. <code>: The Inline Code element
    28. <col>
    29. <colgroup>
    30. <command>: The HTML Command element
    31. <content>: The Shadow DOM Content Placeholder element (obsolete)
    32. <data>
    33. <datalist>: The HTML Data List element
    34. <dd>: The Description Details element
    35. <del>: The Deleted Text element
    36. <details>: The Details disclosure element
    37. <dfn>: The Definition element
    38. <dialog>: The Dialog element
    39. <dir>: The Directory element (obsolete)
    40. <div>: The Content Division element
    41. <dl>: The Description List element
    42. <dt>: The Description Term element
    43. <element>: The Custom Element element (Obsolete)
    44. <em>: The Emphasis element
    45. <embed>: The Embed External Content element
    46. <fieldset>: The Field Set element
    47. <figcaption>: The Figure Caption element
    48. <figure>: The Figure with Optional Caption element
    49. <font>
    50. <footer>
    51. <form>
    52. <frame>
    53. <frameset>
    54. <h1>–<h6>: The HTML Section Heading elements
    55. <head>: The Document Metadata (Header) element
    56. <header>
    57. <hgroup>
    58. <hr>: The Thematic Break (Horizontal Rule) element
    59. <html>: The HTML Document / Root element
    60. <i>: The Idiomatic Text element
    61. <iframe>: The Inline Frame element
    62. <image>: The obsolete Image element
    63. <img>: The Image Embed element
    64. <input>: The Input (Form Input) element
    65. <ins>
    66. <isindex>
    67. <kbd>: The Keyboard Input element
    68. <keygen>
    69. <label>
    70. <legend>
    71. <li>
    72. <link>: The External Resource Link element
    73. <listing>
    74. <main>
    75. <map>
    76. <mark>: The Mark Text element
    77. <marquee>: The Marquee element (Obsolete)
    78. <menu>
    79. <menuitem>
    80. <meta>: The Document-level Metadata element
    81. <meter>: The HTML Meter element
    82. <multicol>: The HTML Multi-Column Layout element (Obsolete)
    83. <nav>: The Navigation Section element
    84. <nextid>: The NeXT ID element (Obsolete)
    85. <nobr>: The Non-Breaking Text element (obsolete)
    86. <noembed>: The Embed Fallback element (Obsolete)
    87. <noframes>: The Frame Fallback element
    88. <noscript>
    89. <object>
    90. <ol>: The Ordered List element
    91. <optgroup>
    92. <option>: The HTML Option element
    93. <output>: The Output element
    94. <p>: The Paragraph element
    95. <param>: The Object Parameter element
    96. <picture>: The Picture element
    97. <plaintext>: The Plain Text element (Deprecated)
    98. <pre>: The Preformatted Text element
    99. <progress>: The Progress Indicator element
    100. <q>: The Inline Quotation element
    101. <rb>: The Ruby Base element
    102. <rp>: The Ruby Fallback Parenthesis element
    103. <rt>: The Ruby Text element
    104. <rtc>: The Ruby Text Container element
    105. <ruby>
    106. <s>
    107. <samp>: The Sample Output element
    108. <script>: The Script element
    109. <section>: The Generic Section element
    110. <select>: The HTML Select element
    111. <shadow>: The obsolete Shadow Root element
    112. <slot>
    113. <small>: the side comment element
    114. <source>: The Media or Image Source element
    115. <spacer>
    116. <span>
    117. <strike>
    118. <strong>: The Strong Importance element
    119. <style>: The Style Information element
    120. <sub>: The Subscript element
    121. <summary>: The Disclosure Summary element
    122. <sup>: The Superscript element
    123. <table>: The Table element
    124. <tbody>: The Table Body element
    125. <td>: The Table Data Cell element
    126. <template>: The Content Template element
    127. <textarea>
    128. <tfoot>: The Table Foot element
    129. <th>
    130. <thead>: The Table Head element
    131. <time>
    132. <title>: The Document Title element
    133. <tr>: The Table Row element
    134. <track>: The Embed Text Track element
    135. <tt>: The Teletype Text element (obsolete)
    136. <u>: The Unarticulated Annotation (Underline) element
    137. <ul>: The Unordered List element
    138. <var>: The Variable element
    139. <video>: The Video Embed element
    140. <wbr>
    141. <xmp>
  10. HTML 参考
  11. 内联元素
  12. Link 类型
    1. Link 类型
    2. Link types: dns-prefetch
    3. Link types: manifest
    4. Link types: modulepreload
    5. Link types: noopener
    6. Link types: noreferrer
    7. Link types: preconnect
    8. Link types: prefetch
    9. Link types: preload
    10. Link types: prerender
  13. Microdata
  14. Microformats
  15. 采用 rel="preload" 预加载内容
  16. Quirks Mode and Standards Mode
  17. Using the application cache

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1