<script type="text/javascript">
//架構自應用高度
function dyniframesize(down) {
var pTar = null;
if (document.getElementById) {
pTar = document.getElementById(down);
}
else {
eval('pTar = ' + down + ';');
}
if (pTar && !window.opera) {
//begin resizing iframe
pTar.style.display = "block"
if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight) {
//ns6 syntax
pTar.height = pTar.contentDocument.body.offsetHeight + 20;
pTar.width = pTar.contentDocument.body.scrollWidth + 20;
}
else if (pTar.Document && pTar.Document.body.scrollHeight) {
//ie5+ syntax
pTar.height = pTar.Document.body.scrollHeight;
pTar.width = pTar.Document.body.scrollWidth;
}
}
}
</script>
在Ifram處設定:
<iframe style="vertical-align: top; padding-left: 0px; height: 447px; width:720px;
background-color: #EAEEED" onload="javascript:dyniframesize('WorkSpace');" id="WorkSpace"
marginwidth="0" scrolling="no" frameborder="0" name="ifram" src="CompanyManage.aspx">
</iframe>
上面這種方法我是在http://bbs.51aspx.com/showtopic-2263.html看來的,但是當你對這個ifram框進行設定了height時,那麼當你的內容超過height時就不能進行拉申了;
以下這種方法他不受你所設定的height的限制:
<script type="text/javascript">
if (window != top) top.location = window.location;
// 調整 Table DesktopFrame 的大小,以使 IFrame WorkSpace 不出現捲軸
function WorkSpaceLoad() {
var h = WorkSpace.document.body.scrollHeight;
if (h > 450)
parent.DesktopFrame.height = h;
parent.document.all.WorkSpace.style.height = h;
}
</script>
在有架構的表格上設定:
<table width="100%" id="DesktopFrame">
<tr>
<td>
<iframe style="vertical-align: top; padding-left: 0px; width: 725px;
background-color: #EAEEED" id="WorkSpace" onload="javascript:WorkSpaceLoad();"
marginwidth="0" scrolling="no" frameborder="0" name="ifram" src="CompanyManage.aspx">
</iframe>
</td>
</tr>
</table>
但是這兩種方法都受到了首次寬度的限制,就是說當你在同一個頁面時,有不同的操作,第一個操作顯示的內容少,第二個操作顯示的內容多;如果說你是先操作第一個,那麼當你操作第二個時頁面的架構是不會自動拉申的;此問題已經困了很久了,如有高手知道怎麼處理請分享一下,非常的感謝,,,,