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.
Specifications
Browser compatibility
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
