Same-origin policy
The same-origin policy is a browser rule that limits how a page or script from one origin can use a resource from another origin. It lets pages embed and link to other origins, but it stops them from reading the data.
Concept
Also called SOP
Updated
On this page
Example
JavaScript on https://example.com
const frame = document.querySelector("iframe"); // src="https://widget.example"
frame.contentWindow.postMessage("hello", "https://widget.example"); // allowed
frame.contentWindow.document; // blocked: throws a SecurityErrorA page can send messages to a cross-origin frame, but it cannot read the frame's document.
Learn more
Sources