Home > Web Front-end > JS Tutorial > body text

jsp page iframe highly adaptive js code

高洛峰
Release: 2017-01-09 09:13:50
Original
1190 people have browsed it

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

<iframe id="agentFrame" name="agentFrame" src="" width="0" height="0" style="display:none;" ></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>
Copy after login

test.jsp如下:

<%@ page contentType="text/html;charset=GBK" language="java"%>
<script>
function pseth() {
var iObj = parent.parent.document.getElementById(&#39;infoFrame&#39;);
iObjH = parent.parent.frames["infoFrame"].frames["agentFrame"].location.hash;
iObj.style.height = iObjH.split("#")[1]+"px";
}
window.onload=pseth();
</script>
Copy after login

    

更多jsp页面iframe高度自适应的js代码相关文章请关注PHP中文网!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!