码迷,mamicode.com
首页 > 其他好文 > 详细

iframe自适应内容高度

时间:2014-10-08 11:29:55      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:io   sp   c   on   cti   r   ad   bs   window   

onload="this.height=this.contentWindow.document.body.scrollHeight"

/**
*上传控件iframe自适应
**/
function iframeautoHeight(obj, frameObj) {
    if (document.all) {
        if (frameObj) {
            obj.height = document.getElementById(frameObj).contentWindow.document.body.scrollHeight;
            obj.width = document.getElementById(frameObj).contentWindow.document.body.scrollWidth;
        } else {
            obj.height = obj.contentWindow.document.body.scrollHeight;
            obj.width = obj.contentWindow.document.body.scrollWidth;
        }
    } else {
        if (frameObj) {
            obj.height = document.getElementById(frameObj).contentWindow.document.body.offsetHeight;
            obj.width = document.getElementById(frameObj).contentWindow.document.body.clientWidth;
        } else {
            obj.height = obj.contentWindow.document.body.offsetHeight;
            obj.width = obj.contentWindow.document.body.clientWidth;
        }
    }
}

iframe自适应内容高度

标签:io   sp   c   on   cti   r   ad   bs   window   

原文地址:http://www.cnblogs.com/miumiu/p/4010612.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!