iframe動態改變內嵌頁面高度,iframe動態內嵌頁面

來源:互聯網
上載者:User

iframe動態改變內嵌頁面高度,iframe動態內嵌頁面

test.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title> New Document </title>  <meta name="Generator" content="EditPlus">  <meta name="Author" content="">  <meta name="Keywords" content="">  <meta name="Description" content=""> </head> <body><table align=center cellspacing=0 cellpadding=0 height="100%" border=0><tbody><tr><td valign="top" width="206" name="frametitle" id="frametitle"><iframe style="z-index: 1; visibility: inherit; width: 206px;height:100%" name="leftmenu" id="leftmenu" src="nest.html" frameborder=0  scrolling="no"></iframe></td></tr></tbody></table> </body></html> <script type="text/javascript">function TuneHeight(){var h = document.getElementById("leftmenu").contentWindow.document.body.scrollHeight + "px";document.getElementById("frametitle").style.height=h;}window.onload=TuneHeight;</script>

nest.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title> New Document </title>  <meta name="Generator" content="EditPlus">  <meta name="Author" content="">  <meta name="Keywords" content="">  <meta name="Description" content="">   <script type="text/javascript">   function test(){document.write("<span>----------------------------------</span>");window.parent.TuneHeight();   }   setInterval(test,1000);  </script> </head> <body>   </body></html>



iframe嵌入的架構的高度,可以根據嵌入的網頁的高度而變化?

好象是不行的!
iframe就像是開了一個窗戶
從這個窗戶裡面看要顯示的頁面
而頁面的大小是任意的
我想你要的效果應該可以用別的方法得到,
這裡面還涉及到捲軸的問題
可以把捲軸的顏色設定一下!^-^
 
iframe內嵌頁面高度

parent.document.getElementById("mainFrame").height = document.documentElement.scrollHeight;
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.