Window: crossOriginIsolated property - Web APIs | MDN
Value
A boolean value.
Examples
Cross-origin isolating a document
To cross-origin isolate a document:
-
Set the
Cross-Origin-Opener-PolicyHTTP header tosame-origin:http
Cross-Origin-Opener-Policy: same-origin -
Set the
Cross-Origin-Embedder-PolicyHTTP header torequire-corporcredentialless:http
Cross-Origin-Embedder-Policy: require-corp Cross-Origin-Embedder-Policy: credentialless -
The
cross-origin-isolateddirective of thePermissions-Policyheader must not block access to the feature. Note that the default allowlist of the directive isself, so the permission will be granted by default to cross-origin isolated documents.
Checking if the document is cross-origin isolated
js
const myWorker = new Worker("worker.js");
if (window.crossOriginIsolated) {
const buffer = new SharedArrayBuffer(16);
myWorker.postMessage(buffer);
} else {
const buffer = new ArrayBuffer(16);
myWorker.postMessage(buffer);
}
Specifications
| Specification |
|---|
| HTML # dom-crossoriginisolated-dev |