HTMLIFrameElement.contentWindow
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
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
Spécification | État | Commentaires |
---|---|---|
HTML Living Standard La définition de 'HTMLIFrameElement: contentWindow' dans cette spécification. |
Standard évolutif |
Compatibilité des navigateurs
BCD tables only load in the browser