jsp页面iframe高度自适应的js代码
以下操作写在body里面,form表单外
<iframeid="agentFrame"name="agentFrame"src=""width="0"height="0"style="display:none;"></iframe>
<scripttype="text/javascript">
functionsethash(){
hashH=document.documentElement.scrollHeight;//获取自身高度
urlC="/test.jsp";//设置iframeA的src
document.getElementById("agentFrame").src=urlC+"#"+hashH;//将高度作为参数传递
}
window.onload=sethash;
</script>
test.jsp如下:
<%@pagecontentType="text/html;charset=GBK"language="java"%>
<script>
functionpseth(){
variObj=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>热门推荐
10 五一公司放假祝福语简短
11 追星女孩的祝福语简短
12 给长辈端午祝福语 简短
13 生日祝福语有诗意简短
14 团圆日祝福语简短
15 中秋商务祝福语简短最新
16 温暖文艺简短祝福语短句
17 男孩上学祝福语简短的
18 入住酒店文案祝福语简短