日期:2014-05-16 浏览次数:20463 次
<iframe id="test-iframe" name="test-iframe" src="child.html" scrolling="no" frameborder="0"></iframe>
<script>
window.onload = function () {
/*
* 下面两种获取节点内容的方式都可以。
* 由于 IE6, IE7 不支持 contentDocument 属性,所以此处用了通用的
* window.frames["iframe Name"] or window.frames[index]
*/
var d = window.frames["test-iframe"].document;
d.getElementsByTagName('h1')[0].innerHTML = 'pp';
alert(d.getElementsByTagName('h1')[0].firstChild.data);
}
</script>