1,适应内容自动扩展,在parent页面上加处理script:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language=JavaScript>
function autoResize(){
try{
document.all["content"].style.height=content.document.body.scrollHeight;
document.all["content"].style.width=content.document.body.scrollWidth;
}
catch(e){}
}
</script>

<style type="text/css">
<!--
body {
margin-left: 100px;
margin-top: 100px;
margin-right: 100px;
margin-bottom: 100px;
background-color: #CCCCCC;
}
-->
</style></head>

<body>
<iframe name="content" style="aho:expression(autoResize())" width="100%" frameborder=0 src="1.htm" scrolling=no></iframe>
</body>
</html>

2.在引用的文件上加script

function changeIframeHeight() //自动改变 Iframe 的高度
{
if(top != self)
   window.parent.document.getElementById(self.name).height = document.body.scrollHeight;
}

function window.onload()
{
   changeIframeHeight(); //改变 Iframe 高度
}

把上面那个放到需要自适应的页面中,用javascript套用就可以了

 

实际上只需要做第一步就OK了,在子页面可以不用添加任何JS代码即可实现

相关文章:

  • 2022-12-23
  • 2021-06-07
  • 2021-12-24
  • 2021-10-05
  • 2022-02-01
  • 2022-12-23
  • 2021-09-14
猜你喜欢
  • 2021-10-03
  • 2022-02-10
  • 2021-12-14
  • 2021-06-01
  • 2021-05-18
  • 2022-02-07
  • 2021-12-12
相关资源
相似解决方案