jsp頁面iframe高度自適應(yīng)的js代碼
更新時間:2014年09月29日 16:59:27 投稿:whsnow
iframe高度自適應(yīng),獲取自身高度,之后將高度作為參數(shù)傳遞,在窗口加載后執(zhí)行就可以了
以下操作寫在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"; //設(shè)置iframeA的src
document.getElementById("agentFrame").src=urlC+"#"+hashH; //將高度作為參數(shù)傳遞
}
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>
您可能感興趣的文章:
相關(guān)文章
搭建Eclipse+MyEclipse開發(fā)環(huán)境
搭建Eclipse+MyEclipse開發(fā)環(huán)境...2007-02-02
JSP 自定義標簽實現(xiàn)數(shù)據(jù)字典的實例
這篇文章主要介紹了JSP 自定義標簽實現(xiàn)數(shù)據(jù)字典的實例的相關(guān)資料,這里實現(xiàn)這樣的功能,希望能幫助到大家,需要的朋友可以參考下2017-08-08

