jsp页面iframe高度自适应的js代码_JSP教程-查字典教程网
jsp页面iframe高度自适应的js代码
jsp页面iframe高度自适应的js代码
发布时间:2016-12-29 来源:查字典编辑
摘要:以下操作写在body里面,form表单外functionsethash(){hashH=document.documentElement.s...

以下操作写在body里面,form表单外

<iframe id="agentFrame" name="agentFrame" src="" width="0" height="0" ></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教程学习
    热门JSP教程学习
    编程开发子分类