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 Standard The definition of 'HTMLIFrameElement: contentDocument' in that specification. |
Living Standard |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
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