讓iframe框架網(wǎng)頁(yè)在任何瀏覽器下自動(dòng)伸縮
更新時(shí)間:2006年08月18日 00:00:00 作者:
很多朋友都在使用iframe中遇到過(guò)不能自動(dòng)隨頁(yè)面伸縮,特別是動(dòng)態(tài)讀取頁(yè)面的時(shí)候,會(huì)出現(xiàn)滾動(dòng)條,影響美觀,今天研究一下了,發(fā)現(xiàn)了一個(gè)簡(jiǎn)單解決的辦法,可以在IE,F(xiàn)IREFOX,OPERA下使用
方法如下,將2段代
碼照提示保存。
請(qǐng)保存為mainframe.htm
<html>
<body>
<div>
<iframe marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0"
id="frametb" scrolling="no" src="frame.htm"
onload="style.width=this.contentWindow.document.all.formfra.offsetWidth;"
+"style.height=this.contentWindow.document.all.formfra.offsetHeight"></iframe>
</div>
</body>
</html>
請(qǐng)保存為frame.htm
<html>
<body leftmargin="0" topmargin="0">
<table id=formfra width=200 border=0 bgcolor=green>
<tr><td>
胡東平在線空間
<p/>
sfsfere
</td></tr>
</table>
</body>
</html>
執(zhí)行mainframe.htm就可以看到效果了。
套用修改的時(shí)候要注意mainframe.htm和frame.htm里面定義表格的ID,然后記得在frame語(yǔ)句中修改相對(duì)應(yīng)的
調(diào)用文件名稱(chēng)和路徑,并且注意下面這句:
onload="style.width=this.contentWindow.document.all.formfra.offsetWidth;"
+"style.height=this.contentWindow.document.all.formfra.offsetHeight"
做相應(yīng)修改
this.contentWindow.document.all.調(diào)用頁(yè)面表格ID.offsetWidth
this.contentWindow.document.all.調(diào)用頁(yè)面表格ID.offsetHeight
記住,一定要定義表格ID。
碼照提示保存。
請(qǐng)保存為mainframe.htm
復(fù)制代碼 代碼如下:
<html>
<body>
<div>
<iframe marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0"
id="frametb" scrolling="no" src="frame.htm"
onload="style.width=this.contentWindow.document.all.formfra.offsetWidth;"
+"style.height=this.contentWindow.document.all.formfra.offsetHeight"></iframe>
</div>
</body>
</html>
請(qǐng)保存為frame.htm
復(fù)制代碼 代碼如下:
<html>
<body leftmargin="0" topmargin="0">
<table id=formfra width=200 border=0 bgcolor=green>
<tr><td>
胡東平在線空間
<p/>
sfsfere
</td></tr>
</table>
</body>
</html>
執(zhí)行mainframe.htm就可以看到效果了。
套用修改的時(shí)候要注意mainframe.htm和frame.htm里面定義表格的ID,然后記得在frame語(yǔ)句中修改相對(duì)應(yīng)的
調(diào)用文件名稱(chēng)和路徑,并且注意下面這句:
復(fù)制代碼 代碼如下:
onload="style.width=this.contentWindow.document.all.formfra.offsetWidth;"
+"style.height=this.contentWindow.document.all.formfra.offsetHeight"
做相應(yīng)修改
復(fù)制代碼 代碼如下:
this.contentWindow.document.all.調(diào)用頁(yè)面表格ID.offsetWidth
this.contentWindow.document.all.調(diào)用頁(yè)面表格ID.offsetHeight
記住,一定要定義表格ID。
相關(guān)文章
javascript使用shift+click實(shí)現(xiàn)選擇和反選checkbox的方法
這篇文章主要介紹了javascript使用shift+click實(shí)現(xiàn)選擇和反選checkbox的方法,涉及javascript針對(duì)鍵盤(pán)按鍵的判斷及checkbox的操作技巧,需要的朋友可以參考下2015-05-05js實(shí)現(xiàn)簡(jiǎn)單的購(gòu)物車(chē)有圖有代碼
這篇文章主要介紹了用js實(shí)現(xiàn)的簡(jiǎn)單購(gòu)物車(chē),配有截圖,適合初學(xué)者2014-05-05JavaScript中解決多瀏覽器兼容性23個(gè)問(wèn)題的快速解決方法
下面小編就為大家?guī)?lái)一篇JavaScript中解決多瀏覽器兼容性23個(gè)問(wèn)題的快速解決方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-05-05Javascript中扁平化數(shù)據(jù)結(jié)構(gòu)與JSON樹(shù)形結(jié)構(gòu)轉(zhuǎn)換詳解
之前朋友問(wèn)過(guò)我一個(gè)問(wèn)題,項(xiàng)目中遇到扁平化數(shù)據(jù)結(jié)構(gòu)不知如何樹(shù)形化,下面這篇文章主要給大家介紹了關(guān)于Javascript中扁平化數(shù)據(jù)結(jié)構(gòu)與JSON樹(shù)形結(jié)構(gòu)轉(zhuǎn)換的相關(guān)資料,需要的朋友可以參考下2022-05-05詳解如何替換項(xiàng)目中的if-else和switch
這篇文章主要為大家介紹了詳解如何替換項(xiàng)目中的if-else和switch,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-11-11