Frame/IFrame contentWindowPropiedad
Frame/IFrame Objeto
Definición y uso
La propiedad contentWindow puede devolver el documento dentro del iframe como un objeto HTML.
El objeto devuelto se puede procesar mediante todos los métodos DOM estándar.
Sintaxis
frameObject.contentWindow
O bien
iframeObject.contentWindow
O bien
iframeObject.contentWindow
Soporte del navegador
![]()
![]()
![]()
![]()
![]()
Todos los navegadores principales soportan la propiedad contentWindow
Ejemplos
Ejemplos
El siguiente ejemplo muestra cómo cambiar el color de fondo del documento contenido en el iframe a través del navegador:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial Ejemplo (example.com)</title>
<script>
function changeStyle(){
var x=document.getElementById("myframe");
var y=(x.contentWindow || x.contentDocument);
if (y.document)y=y.document;
y.body.style.backgroundColor="#0000ff";
}
</script>
</head>
<body>
<iframe id="myframe" src="demo_iframe.htm">
<p>Tu navegador no soporta iframes.</p>
</iframe>
<br><br>
<input type="button" onclick="changeStyle()" value="Cambiar color de fondo">
</body>
</html>
Pruébalo tú mismo »
Frame/IFrame Objeto Otras extensiones