iframe如何获取内部页面中frameset对象

aaa1810 2009-06-17 08:33:16
index页面中有一个iframe链接是a.html页面 :
<iframe src="a.html" name="sysIframe" id="sysIframe" ></iframe>



a.html 页面中就一个 frameset 框架:
  <frameset rows="140,*" cols="*" name="fset">
<frame src="1.html" name="topFrame" .../>
<frame src="2.html" name="centerFrame" ../>
</frameset>


原来直接使用a.html的时候 可以在2.html中使用window.top.frames['topFrame']获取对象

现在用使用iframe的话window.top.frames['topFrame']就获取不到了..

求高手帮忙解答下 很急 谢谢了...

...全文
260 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
natineprince 2009-06-17
  • 打赏
  • 举报
回复 1
window.parent.frames['topFrame']
aaa1810 2009-06-17
  • 打赏
  • 举报
回复
三楼的已经试过 还是提示缺少对象..

william3033 2009-06-17
  • 打赏
  • 举报
回复
把你的frame的id都加上!
xiongzhijian 2009-06-17
  • 打赏
  • 举报
回复
试试三楼的..
aaa1810 2009-06-17
  • 打赏
  • 举报
回复
2L的提示缺少对象..

我把完整的贴出来吧..


<html>
<head>
</head>
<body scroll="no">
<iframe name="aaa" id="xx" src="index.html" style="width:100%; height:100%; border:0" scrolling="no" />
</body>
</html>


Index.html页面的代码

<html>
<head>
</head>
<frameset rows="50,*" cols="*" frameborder="no" border="0" framespacing="0">
<frame src="topframe.html" name="topFrame" frameborder="no" scrolling="No" noresize="noresize" id="topFrame" title="topFrame" />
<frameset name="myFrame" id="myFrame" cols="199,7,*" frameborder="no" border="0" framespacing="0">
<frame src="leftframe.html" name="leftFrame" frameborder="no" scrolling="No" noresize="noresize" id="leftFrame" title="leftFrame" />
<frame src="switchframe.html" name="midFrame" frameborder="no" scrolling="No" noresize="noresize" id="midFrame" title="midFrame" />
<frameset rows="59,*" cols="*" frameborder="no" border="0" framespacing="0">
<frame src="mainframe.html" name="mainFrame" frameborder="no" scrolling="No" noresize="noresize" id="mainFrame" title="mainFrame" />
<frame src="manframe.html" name="manFrame" frameborder="no" id="manFrame" title="manFrame" />
</frameset>
</frameset>
</frameset>
<noframes><body>
</body>
</noframes>
</html>


在leftframe.Html中 有这样一行JS代码 window.top.frames['manFrame']

现在如何在leftframe中获取manFrame..
helanye 2009-06-17
  • 打赏
  • 举报
回复
用document.getElementById("sysIframe").document.frames["topFrame"]
不行的话,
可以用document.getElementById("sysIframe").contentWindow.document.frames["topFrame"];
william3033 2009-06-17
  • 打赏
  • 举报
回复
top.sysIframe.frames['topFrame']
shenzhenNBA 2009-06-17
  • 打赏
  • 举报
回复

JS操作:
document.getElementById("sysIframe").document.frames["topFrame"]
试看....

87,909

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧