网络编程 
首页 > 网络编程 > 浏览文章

让iframe框架网页在任何浏览器下自动伸缩

(编辑:jimmy 日期: 2025/5/15 浏览:3 次 )
方法如下,将2段代
码照提示保存。
请保存为mainframe.htm
复制代码 代码如下:
<html> 
<body> 
<div> 
<iframe marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" 
id="frametb" scrolling="no" src="/UploadFiles/2021-04-02/frame.htm">onload="style.width=this.contentWindow.document.all.formfra.offsetWidth;"
+"style.height=this.contentWindow.document.all.formfra.offsetHeight"></iframe> 
</div> 
</body> 
</html>

请保存为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>


执行mainframe.htm就可以看到效果了。
套用修改的时候要注意mainframe.htm和frame.htm里面定义表格的ID,然后记得在frame语句中修改相对应的
调用文件名称和路径,并且注意下面这句:
复制代码 代码如下:
onload="style.width=this.contentWindow.document.all.formfra.offsetWidth;"
+"style.height=this.contentWindow.document.all.formfra.offsetHeight"

做相应修改
复制代码 代码如下:
this.contentWindow.document.all.调用页面表格ID.offsetWidth
this.contentWindow.document.all.调用页面表格ID.offsetHeight

记住,一定要定义表格ID。 
上一篇:用srcElement实现添加效果 原创
下一篇:移到这里,就会自动点击
一句话新闻
高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 网站地图 SiteMap