?
Ce document utilise Manuel du site Web PHP chinois Libérer
在HTML5中,一些 HTML 元素提供了對 CORS 的支持, 例如<img>
和 <video>
均有一個跨域屬性 (crossOrigin
property),它允許你配置元素獲取數據的 CORS 請求。 這些屬性是枚舉的,并具有以下可能的值:
關鍵詞 | 描述 |
---|---|
匿名 | 此元素的CORS請求將不會設置憑證標志。 |
使用的憑據 | 此元素的CORS請求將設置憑證標志; 這意味著請求將提供憑據。 |
默認情況下 (即未指定crossO
rigin屬性時), CORS 根本不會使用。如Terminology section of the CORS specification 中的描述, “anonymous" 關鍵字說明不會通過 cookies,客戶端 SSL 證書或 HTTP 認證交換用戶憑據。
即使是無效的關鍵字和空字符串也會被當作 anonymous
關鍵字使用。
你可以使用下面的<script>
元素告訴一個瀏覽器執(zhí)行來自 https://example.com/example-framework.js
的腳本而不發(fā)送用戶憑據。
<script src="https://example.com/example-framework.js" crossorigin="anonymous"></script>
規(guī)范 | 狀態(tài) | 評論 |
---|---|---|
HTML Living Standard該規(guī)范中'CORS設置屬性'的定義。 | 生活水平 | |
HTML生活標準該規(guī)范中'跨部門'的定義。 | 生活水平 |
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 13 | 8.0 (8.0) | 11 | No support | (Yes) |
<video> | ? | 12.0 (12.0) | ? | ? | ? |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | ? | 8.0 (8.0) | ? | ? | (Yes) |
<video> | ? | 12.0 (12.0) | ? | ? | ? |