我有下面的代码。 inviter
嵌入在myscript.js
中。 https://example.com/iframe3.html
嵌入在iframe3.html
中。我的问题是,如何更改homepage.html
,以使其能够在iframe之外获取内容。本质上,我试图抢myscript.js
和id="name"
。
myscript.js
id="age-i"
homepage.html
var ifr = document.createElement("iframe");
var theage = document.getElementById("age-i").innerHTML;
ifr.src = "https://example.com/get.php?age-i=" + theage;
ifr.style.visibility = "hidden";
document.body.appendChild(ifr);
iframe3.html
<td width="340" align="right">
<div id="userarea">
<div>
<div id="userarea-line1">
<a href="#"><img src="/common/img/icons/home.png" width="14" height="14" /></a> <a id="name" href="#"><span class='notranslate'>John</span></a> | <a href="#">Account</a> | <a href="#" style="margin-right:5px;">Smith</a> </div>
<div id="userarea-line2"> <img width="10" height="11" src="/common/skin/base/icons/icn_age.gif" /> <span class="age-format"> <a href="#"><strong id="age-i"><span class='notranslate'>26</span></strong> age</a>
</span> <img width="10" height="11" align="top" src="/common/skin/base/icons/icn_age.gif" /> <span class="age-format" style="margin-right:5px;"> <span id="month-i"> <span class='notranslate'>03</span> </span> month</span>
</div>
</div>
</div>
</td>
<iframe id="myframe_content" frameborder="0" src="https://example.com/iframe3.html" name="myframe_content"></iframe>
答案 0 :(得分:0)
我相信现有的stackoverflow帖子:accessing elements of one iframe from another iframe应该回答您的问题。
谢谢,
赤丹