HTML5 中 cross-origin 屬性的用法是什麼?
官方規範將 cross-origin 屬性定義為 −
The crossorigin attribute is a CORS settings attribute. Its purpose is to allow images from third-party sites that allow cross-origin access to be used with canvas.
當它與 CORS header 結合時,它允許使用載入來自外域的元素定義的影像,用於畫布中。過程就像從當前域載入一樣。
可以使用它來解決 JavaScript 錯誤,例如記錄 js 錯誤 −
if (securityOrigin()->canRequest(targetUrl)) {
msg = myError;
line = myLineNumber;
source = sourceURL;
} else {
msg = "Error!";
source = String();
line = 0;
}
Advertisement
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP