簡體   English   中英

有沒有一種方法可以根據需要擴展iframe?

[英]Is there a way to make an Iframe expandable as needed?

有沒有一種方法可以根據需要擴展iframe? 我有一個帶有iframe的網頁,到同一服務器上的第二個網頁。 第二個網頁有一個可擴展的表。 我想要的是,當某人通過iframe查看第二頁並單擊表格以展開時,iframe也會進行擴展以適合其尺寸。

<script type="text/javascript">
//<![CDATA[
window.onload = function() {
var f = document.getElementById("mainframe");
function resize() {
var h = "";
var w = "";
if (f.contentDocument) {
h = f.contentDocument.documentElement.offsetHeight + 20 + "px";
(f.contentDocument.documentElement,"").getProperty Value

("width");
} else if (f.contentWindow) {
h = f.contentWindow.document.body.scrollHeight + 5 + "px";
} else {
return;
}
f.setAttribute("height",h);
f.parentNode.setAttribute("height",h);
}
if (window.addEventListener) {
f.onload = resize;
} else if (f.attachEvent) {
f.attachEvent("onload", resize);
} else {
return;
}
resize();
}
//]]>
</script>

<iframe name="frm" id="mainframe" src="URL HERE" frameborder="0" allowtransparency="no" scrolling="no" target="_self" height="150"></iframe>

這是HTML代碼:

<a href="URL OF PAGE" target="content">Name Of Page</a>

如果在這種情況下頁面位於同一域中,則以下解決方案應該起作用。

使iframe無需使用滾動條即可根據內容自動調整高度?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM