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 生日广州男生祝福语简短