HTMLIFrameElement.contentWindow

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

La propriété contentWindow renvoie l'objet Window d'un élément <iframe>. Cet objet Window peut être utilisé pour accéder au document de l'iframe et à son DOM. Cet attribut est en lecture seule mais ses propriétés peuvent être manipulées comme pour l'objet global Window.

Exemples

js
var x = document.getElementsByTagName("iframe")[0].contentWindow;
//x = window.frames[0];

x.document.getElementsByTagName("body")[0].style.backgroundColor = "blue";
// ceci devrait changer le 1er iframe dans le document bleu.

Spécifications

Specification
HTML
# dom-iframe-contentwindow

Compatibilité des navigateurs

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
contentWindow

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support