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 生日开业蛋糕祝福语简短