欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

iframe 自適應(yīng)高度[在IE6 IE7 FF下測(cè)試通過(guò)]

 更新時(shí)間:2009年04月13日 10:41:45   作者:  
有時(shí)候我們需要讓我們的iframe自動(dòng)適應(yīng)高度,但多瀏覽器兼容性不好,大家不妨試下這個(gè)。
第一種方法:
復(fù)制代碼 代碼如下:

<script type="text/javascript" language="javascript">
<!--
//調(diào)整 PageContent 的高度
function TuneHeight() {
var frm = document.getElementById("content01");
var subWeb = document.frames ? document.frames["content01"].document : frm.contentDocument;
if(frm != null && subWeb != null) {
frm.height = subWeb.body.scrollHeight;
}
}
//-->
</script>

<iframe id="content01" name="content01" frameBorder=0 scrolling=no src="main.html" width="100%"onLoad="TuneHeight()" ></iframe>

第二種方法:
js code:
復(fù)制代碼 代碼如下:

//iframe自適應(yīng)高度[在IE6 IE7下測(cè)試通過(guò)]
function reSetIframe(){
var iframe = document.getElementById("iframeId");
try{
var bHeight = iframe.contentWindow.document.body.scrollHeight;
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight);
iframe.height = height;
}catch (ex){}
}

html:
復(fù)制代碼 代碼如下:

<iframe src="" id="weather" name="weather" width="278" onload="reSetIframe()" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" border="0" framespacing="0"> </iframe>

相關(guān)文章

最新評(píng)論