动态的改变IFrame的高度实现IFrame自动伸展适应高度
2016-11-23技术共享Jervois3765°c
A+ A-具体实现一:
1、在IFrame的具体页面(就是子页面),添加JavaScript
var obj = parent.document.getElementById("childFrame");var Time_Status = undefined; obj.height = document.body.scrollHeight; document.body.onmousedown = function(){ if (Time_Status !== undefined) return ; Time_Status = setInterval(function(){ obj.height = document.body.scrollHeight; },10); } document.body.onmouseup = function(){ setTimeout(function(){ clearInterval(Time_Status); Time_Status = undefined; },100); }
2、为父页面的IFrame标签添加ID,即上面第一步,方法体中的第2行所写到的childFrame
<IFRAME border=0 marginWidth=0 frameSpacing=0 marginHeight=0 src="frame1.php" frameBorder=0 noResize scrolling="no" width=100% height=100% vspale="0" id="childFrame"></IFRAME>
标签:IFrame