架構頁面如下:
<div id="aa" style="float: left; height: 500px; border-right-style: solid; border-right-color: #CCCCFF; border-right-width: 2px;">
<IFRAME id="tree" name="tree"
src="/ScienProjectWeb/commonjsp/selectdepartment.jsp?classid=${Hthm_DefaultClassid}&user=1"
frame248px" scrolling="auto" height="95%" allowtransparency>
</IFRAME>
</div>
<div style="float: left;">
<div id="ttr" style="scrolling: auto;height: 300px;border:1px solid blue;">
<IFRAME id="opertop" name="opertop"
src="/ScienProjectWeb/commonjsp/userlist.jsp"
frame width="100%" scrolling="auto" height="100%" allowtransparency>
</IFRAME>
</div>
<div style="height: 200px;border:1px solid blue;">
<IFRAME id="operbottom" name="operbottom"
src="#" frame
width="100%" scrolling="auto" allowtransparency>
</IFRAME>
</div>
</div>
在tree頁面中想要重新整理opertop頁面内容,兩種方法:
第一種:window.parent.document.getElementById("opertop").src=url;(有無window.都可),注意,此處不能用window.parent.frames["opertop"].src=url;
第二種(推薦,将三個頁面互相傳遞資訊的方法統一放在父頁面中,集中管理)
在父頁面中定義方法
function refreshframe(url)
{
//window.frames['opertop'].src=url;這種寫法也不對,隻能通過document.getElementById方式
$('#opertop').attr("src",url);
}
子頁面中調用
parent.refreshframe(url);