contentDocument
Definition and Usage:
The contentDocument property returns the Document object generated by a frame or iframe element.
This property can be used in the host window to access the Document object that belongs to a frame or iframe element.
Note: Because of security reasons, the contents of a document can be accessed from another document only if the two documents are located in the same domain.
Syntax:
frameObject.contentDocument or iframeObject.contentDocument
eg:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript">
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>Your browser does not support iframes.</p>
</iframe>
<br /><br />
<input type="button" onclick="changeStyle()" value="Change background color" />
</body>
</html>
contentWindow
Definition and Usage:
The contentWindow property returns the Window object generated by a frame or iframe element (through the window object, you can access the document object and then any one of the document's elements).
Syntax:
frameObject.contentWindow or iframeObject.contentWindow
相关推荐
没有永恒的技术只有变态的需求,没有好说的客户只有无奈的开发者,如果iframe的出现是一个错误的话,iframe里边在来一个iframe那是错上加错,神话没有在远古的尘嚣中消失,却在怀具的今天不断上演
这里要理解框架的两个属性 contentWindow 和contentDocument 两个属性的意思和window document意思差不多,不同的是contentWindow 所有浏览器都支持,contentDocument ie6,7不支持,chrome 也不支持 <iframe ...
在开始之前,首先我们来看看如何获取iframe里的内容,获取iframe中内容主要的两个API就是contentWindow,和contentDocument iframe.contentWindow, 获取iframe的window对象 iframe.contentDocument, 获取iframe的...
本文实例讲述了JS修改iframe页面背景颜色的方法。分享给大家供大家参考。具体如下: ...var y=(x.contentWindow || x.contentDocument); if (y.document)y=y.document; y.body.style.backgroundColor="#0000
<iframe id= “myframe” ></iframe> W3C的标准告诉我们,可以通过Dom对象的contentDocument属性来... 跨浏览器的解决方案是, contentWindow属性,这是个只读属性,返回指定的iframe的窗口对象。 它虽然不
window.opera) { if (cwin.contentDocument && cwin.contentDocument.body.offsetHeight) cwin.height = cwin.contentDocument.body.offsetHeight + 20; else if(cwin.Document && cwin.Document.body.scrollHe
1. 获得iframe的window对象...文章Iframes, onload, and document.domain中说“he iframe element object has a property called contentDocument that contains the iframe’s document object, so you can use the
js跨域是个讨论很多的话题。iframe跨域访问也被研究...如果支持contentDocument也可以直接document.getElementById(“myframe”).contentDocument访问子页面内容; 子页访问父页,可以parent.js全局属性 二、 是不同主
今天忽然想着复习一下富文本编辑器的制作原理。于是二话不说将手把手地做了起来。... var idoc = ifr.contentDocument || ifr.contentWindow.document; idoc.designMode = ‘on’; idoc.contentEditable = true; id
iframe 自动获取onload高宽 代码如下: function AutoResize(iframe) { //firefox if(iframe.contentWindow) { iframe.height = iframe.contentWindow.... } //IE else if(iframe.contentDocument) { iframe.height =
/* @license * jQuery.print, version 1.3.2 * (c) Sathvik Ponangi, Doers' Guild ... *--------------------------------------------------------------------------*/ (function ($) { "use strict";...
原理为调用 window.print() 方法,但是该方法只能对当前页面全部打印,所以有了以下方案来解决局部打印 1: 利用 iframe 将需要... const content = ifElement.contentWindow || ifElement.contentDocument content.doc