0

我有这个环境:

页1.html:

<iframe id="ifr" name="nifr" src="Page2.html" enableviewstate="true" width="800" height="600" frameborder="1" style="z-index:0" ><p>Su navegador no soporta iframes.</p></iframe>

页面2.html:

<frameset rows="30,*" frameborder="no" framespacing="0">
    <frame id="titleFrame" frameborder="no" marginwidth="0" marginheight="0" scrolling="no" src="title.html">
    <frame id="viewerFrame" frameborder="no" marginwidth="0" marginheight="0" scrolling="no" src="anotherPage.html">
</frameset>

如何使用 javascript 获取框架“viewerFrame”?我只在 Internet Explorer 上工作

提前致谢

4

2 回答 2

2

首先,您将为name框架元素添加一个 - 属性。

<frameset rows="30,*" frameborder="no" framespacing="0">
<frame name="titleFrame" id="titleFrame" frameborder="no" marginwidth="0" marginheight="0" scrolling="no" src="title.html">
<frame name="viewerFrame" id="viewerFrame" frameborder="no" marginwidth="0" marginheight="0" scrolling="no" src="anotherPage.html">
</frameset>

然后你可以从 Page1.html 试试这个:

var viewerFrame=document.getElementById('ifr').contentWindow.viewerFrame;

于 2012-04-13T19:56:38.590 回答
0

如果我理解您想要正确执行的操作,您可能正在搜索类似的内容:

$("#ifr").contentWindow.$("#viewerFrame").html();
于 2012-04-13T19:54:56.650 回答