The contentWindow
property returns the Window object of an HTMLIFrameElement. You can use this Window
object to access the iframe's document and its internal DOM. This attribute is read-only, but its properties can be manipulated like the global Window
object.
Example of contentWindow
var x = document.getElementsByTagName("iframe")[0].contentWindow; //x = window.frames[0]; x.document.getElementsByTagName("body")[0].style.backgroundColor = "blue"; // this would turn the 1st iframe in document blue.
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'HTMLIFrameElement: contentWindow' 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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
contentWindow | Chrome Full support 1 | Edge Full support 12 | Firefox Full support 1 | IE Full support 8 | Opera Full support 8 | Safari Full support 3 | WebView Android Full support 1 | Chrome Android Full support 18 | Firefox Android Full support 4 | Opera Android Full support 10.1 | Safari iOS Full support 1 | Samsung Internet Android Full support 1.0 |
Legend
- Full support
- Full support