iframe高度自适应
2012-02-17 20:14 边缘er 阅读(127) 评论(0) 收藏 举报根据KouBei的UED的方法改进,webkit内页浏览器测试需要环境。
function heightIframe(iframeId){
var iframe = document.getElementById(iframeId);
try{
var bHeight = iframe.contentWindow.document.body.scrollHeight;
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight);
iframe.height = height;
}catch (ex){}
window.setTimeout(function(){heightIframe(iframeId)},200);
}
heightIframe('frame_content');
浙公网安备 33010602011771号