2009年3月25日 星期三

調整東西

thtymytmyum使用iframe來嵌入內置框架時,高度是最難控制的,所以一般都會將scrolling設為"yes"或"auto"來產生捲軸,這樣會使得顯示的範圍變小,因此下面這段程式碼便能解決高度的問題:
將這段程式碼放在前
<script language="javascript" type="text/javascript"> function iFrameHeight() { var h = 0; if ( !document.all ) { h = document.getElementById('blockrandom').contentDocument.height; document.getElementById('blockrandom').style.height = h + 60 + 'px'; } else if( document.all ) { h = document.frames('blockrandom').document.body.scrollHeight; document.all.blockrandom.style.height = h + 20 + 'px'; } } </script>

將這段程式碼放在框架顯示的位置並修改「框架頁URL」
<iframe class="wrapper" id="blockrandom" name="iframe" align="top" src="框架頁URL" frameborder="0" width="100%" scrolling="no" onload="iFrameHeight()" height="500">這個選項無法正常運作。您的瀏覽器不支援內置框架</iframe>