HTMLIFrameElement.contentWindow

The contentWindow property returns the Window object of an <iframe> element. 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.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support43 Yes Yes Yes Yes6
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes Yes Yes Yes Yes Yes ?

Document Tags and Contributors

Contributors to this page: fscholz, gdgsdg123, bantya, cPhost, Tigt, eharris, teoli, liferunsoncode
Last updated by: fscholz,