Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> JavaScript

Có thuộc tính cross-origin trong HTML5 không?

Có, đặc tả chính thức quy định thuộc tính cross-origin như sau:

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.

Bạn có thể dùng nó để giải quyết lỗi JavaScript như log js errors:

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