Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

มีแอตทริบิวต์ cross-origin ใน HTML5 หรือไม่?


มีครับ ข้อกำหนดอย่างเป็นทางการ ระบุแอตทริบิวต์ 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.

คุณสามารถใช้เพื่อแก้ไขข้อผิดพลาด JavaScript เช่น การ log js errors:

if (securityOrigin()->canRequest(targetUrl)) {
  msg = myError;
  line = myLineNumber;
  source = sourceURL;
} else {
  msg = "Error!";
  source = String();
  line = 0;
}