Skip to content

Latest commit

 

History

History
25 lines (22 loc) · 936 Bytes

iframe_size.md

File metadata and controls

25 lines (22 loc) · 936 Bytes

How to calculate the size of an iFrame Back

var calcPageHeight = function(doc) {
    var cHeight = Math.max(doc.body.clientHeight, doc.documentElement.clientHeight);
    var sHeight = Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight);
    return Math.max(cHeight, sHeight);
};

var calcPageWidth = function(doc, win) {
    if (!!win.ActiveXObject && doc.documentMode <= 8 && doc.compatMode === 'CSS1Compat') {
        /**
         * extract the minimal value under IE compatible mode,
         * so that the scroll bar won't be outside the container
         */
        var cWidth = Math.min(doc.body.clientWidth, doc.documentElement.clientWidth);
        /** also set body width to fix existence of scrollbars. */
        // doc.body.style.width = cWidth - 30 + 'px';

        return cWidth;
    } else {
        return Math.max(doc.body.clientWidth, doc.documentElement.clientWidth);
    }
};