您好,欢迎访问一九零五行业门户网

jsp页面iframe高度自适应的js代码

以下操作写在body里面,form表单外
<iframe id="agentframe" name="agentframe" src="" width="0" height="0" style="display:none;" ></iframe> <script type="text/javascript"> function sethash(){ hashh = document.documentelement.scrollheight; //获取自身高度 urlc = "/test.jsp"; //设置iframea的src document.getelementbyid("agentframe").src=urlc+"#"+hashh; //将高度作为参数传递 } window.onload=sethash; </script>
test.jsp如下:
<%@ page contenttype="text/html;charset=gbk" language="java"%> <script> function pseth() { var iobj = parent.parent.document.getelementbyid('infoframe'); iobjh = parent.parent.frames["infoframe"].frames["agentframe"].location.hash; iobj.style.height = iobjh.split("#")[1]+"px"; } window.onload=pseth(); </script>
更多jsp页面iframe高度自适应的js代码。
其它类似信息

推荐信息