Marco HTML DOM / iframe propiedad contentDocument
Definición y Uso
contentDocument propiedad para acomodar el documento marco de objeto HTML devuelto.
Pueden manejar objetos son devueltos por todos los métodos DOM estándar.
Nota: Por razones de seguridad, el contenido del documento sólo se puede acceder por cualquier otro documento con el mismo nombre de dominio.
gramática
frameObject.contentDocument
或者
iframeObject.contentDocument
或者
iframeObject.contentDocument
Soporte para el navegador
Todos los principales navegadores soportan la propiedad contentDocument
!Nota: Si especifica un DOCTYPE, Internet Explorer 8 y versiones posteriores admiten la propiedad contentDocument, utilice la otra versión de IE contentWindow propiedad.
Ejemplos
Ejemplos
Navegador ejemplo muestra cómo modificar el color de fondo iframe documento:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.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>你的浏览器不支持iframes。</p>
</iframe>
<br><br>
<input type="button" onclick="changeStyle()" value="修改背景颜色">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.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>你的浏览器不支持iframes。</p>
</iframe>
<br><br>
<input type="button" onclick="changeStyle()" value="修改背景颜色">
</body>
</html>
Trate »
Frame / objetos IFrame