Web/API/HTMLIFrameElement/contentDocument

From Get docs

If the iframe and the iframe's parent document are Same Origin, returns a Document (that is, the active document in the inline frame's nested browsing context), else returns null.

Example of contentDocument

var iframeDocument = document.getElementsByTagName("iframe")[0].contentDocument; 

iframeDocument.body.style.backgroundColor = "blue";
// This would turn the iframe blue.

Specifications

Specification Status Comment
HTML Living StandardThe definition of 'HTMLIFrameElement: contentDocument' in that specification. Living Standard  

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
contentDocument Chrome

Full support 43

Edge

Full support 12

Firefox

Full support Yes

IE

Full support 8

Opera

Full support Yes

Safari

Full support 10

WebView Android

Full support Yes

Chrome Android

Full support Yes

Firefox Android

Full support 4

Opera Android

Full support Yes

Safari iOS

Full support Yes

Samsung Internet Android

Full support Yes

Legend

Full support  
Full support