现在的位置: 首页HTML, JAVASCRIPT>正文
js实现iframe高度自适应
发表于243 天前 HTML, JAVASCRIPT 暂无评论

代码如下:
[code]
function reinitIframe(){
var iframe = document.getElementById("frame_content");
try{
var bHeight = iframe.contentWindow.document.body.scrollHeight;
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight);
iframe.height = parseInt(dHeight)-140;
}
catch (ex){}
}
window.setInterval("reinitIframe()", 200);
[/code]

给我留言

留言无头像?


×
腾讯微博