HTMLIFrameElement: contentDocument property
HTML DOM
HTML DOM
The contentDocument read-only property of the HTMLIFrameElement interface returns a Document (that is, the active document in the inline frame's nested browsing context) if the iframe and the iframe's parent document are Same Origin, else returns null.
Example of contentDocument
const iframeDocument = document.querySelector("iframe").contentDocument;
iframeDocument.body.style.backgroundColor = "blue";
// This would turn the iframe blue.