iframe自适应内容高度

var frame = document.getElementById('#frame'), 
    win = frame.contentWindow, 
    doc = win.document, 
    html = doc.documentElement, 
    body = doc.body; 

// 获取高度 
var height = Math.max( body.scrollHeight, body.offsetHeight, 
                       html.clientHeight, html.scrollHeight, html.offsetHeight ); 

frame.setAttribute('height', height);

posted @ 2015-11-03 16:53  taony  阅读(137)  评论(0)    收藏  举报