jsp page iframe highly adaptive js code
- 2021-07-03 00:44:28
- OfStack
The following actions are written inside body and outside form 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; // Get your own height
urlC = "/test.jsp"; // Settings iframeA Adj. src
document.getElementById("agentFrame").src=urlC+"#"+hashH; // Passing Height as a Parameter
}
window.onload=sethash;
</script>
test. jsp is as follows:
<%@ 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>