iframe引用页面中的js操作父窗口标签

假设有页面A,里面有iframe标签Frame,iframe引用页面B,在页面B中写js来操作页面A。方法如下:

A.html

<iframe name="Frame" id="Frame" src="B.html" />

 在B页面的js中获取其所在的iframe:

var frame = window.parent.document.getElementById("Frame");

获取该iframe下的Document:

var cDocument = frame.contentWindow.document;

获取该iframe所在的Document:

var pDocument = window.parent.document;

然后便可执行各种操作

 

 

 

posted @ 2013-05-27 13:37  爹子王  阅读(347)  评论(0编辑  收藏  举报