实现让iframe高度伸缩自如没有滚动条(随子页面的高度调整)
html部分
<iframe id="indexFrame" name="win" width="1000" height="100%" οnlοad='dyniframesize("indexFrame")'
src="<%=request.getContextPath()%>/student/studentUpdateTongJi!studentInfoTongJi.action"
frameborder="0" marginwidth="0" marginheight="0" scrolling="no" style="margin-bottom:0px;display: block;"></iframe>
js部分
//让iframe高度伸缩自如没有滚动条
function dyniframesize(down) {
var pTar = null;
if (document.getElementById){
pTar = document.getElementById(down);
}
else{
eval('pTar = ' + down + ';');
}
if (pTar && !window.opera){
//begin resizing iframe
pTar.style.display="block"
if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){
//ns6 syntax
pTar.height = pTar.contentDocument.body.offsetHeight +20;
pTar.width = pTar.contentDocument.body.scrollWidth+20;
}
else if (pTar.Document && pTar.Document.body.scrollHeight){
//ie5+ syntax
pTar.height = pTar.Document.body.scrollHeight;
pTar.width = pTar.Document.body.scrollWidth;
}
}
}