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 头部结合使用时,它将允许从外部来源加载的、由 <img> 元素定义的图像在 canvas 中使用。此过程就像从当前来源加载一样。
你可以使用它来解决 JavaScript 错误,例如记录 js 错误 −
if (securityOrigin()->canRequest(targetUrl)) {
msg = myError;
line = myLineNumber;
source = sourceURL;
} else {
msg = "Error!";
source = String();
line = 0;
}
广告
数据结构
网络
关系数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言
C++
C#
MongoDB
MySQL
JavaScript
PHP