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 红包祝福语简短10字
18 周六早晨祝福语简短