1. 程式人生 > >如何讓iframe的高度自適應父視窗的高度

如何讓iframe的高度自適應父視窗的高度

給iframe新增屬性onload="javascript:this.height=this.contentWindow.document.body.scrollHeight+30;"

如:

<Iframe src="<%= request.getContextPath() %>/listColumnAction.do" width="100%" style="_width: 100%;"
     height="100" scrolling="auto" frameborder="0" name="main" onload="javascript:this.height=this.contentWindow.document.body.scrollHeight+30;"

></iframe>