解决iframe自适应高度
其实很简单,所以高手就不看了哈
方法一:
<iframe id="ifr" name="ifr" src="ifr_content.jsp" frameborder="0" scrolling="no"
onload="this.style.height=ifr.document.body.scrollHeight+50" height="auto" width="100%"></iframe>
onload="this.style.height=ifr.document.body.scrollHeight+50" height="auto" width="100%"></iframe>
方法二:
<body onloade="IFrameResize()">
<iframe id="ifr" name="ifr" src="ifr_content.jsp>" frameborder="0" scrolling="no"
height="auto" width="100%"></iframe>
<script>
function IFrameResize(){
var obj = parent.document.getElementById("ifr"); //取得父页面IFrame对象
obj.height = this.document.body.scrollHeight; //调整父页面中IFrame的高度为此页面的高度
}
</script>
</body>
<iframe id="ifr" name="ifr" src="ifr_content.jsp>" frameborder="0" scrolling="no"
height="auto" width="100%"></iframe>
<script>
function IFrameResize(){
var obj = parent.document.getElementById("ifr"); //取得父页面IFrame对象
obj.height = this.document.body.scrollHeight; //调整父页面中IFrame的高度为此页面的高度
}
</script>
</body>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步