jquery取iframe父页面或frameset中其余frame中的对象

jquery取iframe父页面或frameset中其他frame中的对象

1、取iframe父页面中的对象

index.html

<div id="x1" style="width:500px; height:400px; border:1px solid #000;">你是我天边最美的云彩</div>
<div id="x2" style="width:500px; height:400px; border:1px solid #000;">
<iframe id="cframe" src="child.html"></iframe>
</div>
 child.html  中js

var x = $(window.parent.document).find("#x1").text();

 

 2、去frameset中其他frame中对象

index.html

<FRAMESET border="0" frameSpacing="0" rows="100, *">
	<FRAME name="topFrame" id="top" src="./top.html" />
	<FRAME name="mainFrame" id="main" src="./main.html"/>
</FRAMESET>

 main.html

<div id="x1" style="width:500px; height:400px; border:1px solid #000;">你是我天边最美的云彩</div>

 top.html中取main.html中的值

var x = $(window.parent.frames["topFrame"].document).find("#x1").text();