国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

JavaScript自動設置IFrame高度的小例子

2019-11-20 22:39:38
字體:
來源:轉載
供稿:網友

復制代碼 代碼如下:

function SetIFrameHeight(down) {
        var Sys = {};
        var ua = navigator.userAgent.toLowerCase();
        var s;
        (s = ua.match(/msie ([/d.]+)/)) ? Sys.ie = s[1] :
        (s = ua.match(/firefox//([/d.]+)/)) ? Sys.firefox = s[1] :
        (s = ua.match(/chrome//([/d.]+)/)) ? Sys.chrome = s[1] :
        (s = ua.match(/opera.([/d.]+)/)) ? Sys.opera = s[1] :
        (s = ua.match(/version//([/d.]+).*safari/)) ? Sys.safari = s[1] : 0;
        var pTar = null;
        if (document.getElementById) {
            pTar = document.getElementById(down);
        } else {
            eval('pTar=' + down + ';');
        }
        pTar.style.display = "block";
        if (Sys.ie) {
            if (Sys.ie == '9.0') {
                pTar.height = pTar.contentWindow.document.body.offsetHeight + 15 + "px";
                pTar.width = pTar.contentWindow.document.body.scrollWidth + "px";
            } else if (Sys.ie == '8.0') {
                debugger;
                pTar.height = pTar.Document.body.offsetHeight + 15 + "px";
                pTar.width = pTar.Document.body.scrollWidth + "px";
            } else {
                pTar.height = pTar.Document.body.scrollHeight + 25 + "px";
                pTar.width = pTar.Document.body.scrollWidth + "px";
            }
        }
        if (Sys.firefox) {
            pTar.height = pTar.contentDocument.body.offsetHeight + 15 + "px";
            pTar.width = pTar.contentDocument.body.scrollWidth + "px";
        }
        if (Sys.chrome) {
            pTar.height = pTar.contentDocument.body.offsetHeight;
            pTar.width = pTar.contentDocument.body.scrollWidth;
        }
        if (Sys.opera) {
            pTar.height = pTar.contentDocument.body.offsetHeight;
            pTar.width = pTar.contentDocument.body.scrollWidth;
        }
        if (Sys.safari) {
            if (pTar.contentDocument.body.offsetHeight <= '186') {
                pTar.height = pTar.contentDocument.body.offsetHeight + 10;
            } else {
                pTar.height = pTar.contentDocument.body.offsetHeight;
            }
            pTar.width = pTar.contentDocument.body.scrollWidth;
        }
    }

function SetIFrameHeight(down) {
        var Sys = {};
        var ua = navigator.userAgent.toLowerCase();
        var s;
        (s = ua.match(/msie ([/d.]+)/)) ? Sys.ie = s[1] :
        (s = ua.match(/firefox//([/d.]+)/)) ? Sys.firefox = s[1] :
        (s = ua.match(/chrome//([/d.]+)/)) ? Sys.chrome = s[1] :
        (s = ua.match(/opera.([/d.]+)/)) ? Sys.opera = s[1] :
        (s = ua.match(/version//([/d.]+).*safari/)) ? Sys.safari = s[1] : 0;
        var pTar = null;
        if (document.getElementById) {
            pTar = document.getElementById(down);
        } else {
            eval('pTar=' + down + ';');
        }
        pTar.style.display = "block";
        if (Sys.ie) {
            if (Sys.ie == '9.0') {
                pTar.height = pTar.contentWindow.document.body.offsetHeight + 15 + "px";
                pTar.width = pTar.contentWindow.document.body.scrollWidth + "px";
            } else if (Sys.ie == '8.0') {
                debugger;
                pTar.height = pTar.Document.body.offsetHeight + 15 + "px";
                pTar.width = pTar.Document.body.scrollWidth + "px";
            } else {
                pTar.height = pTar.Document.body.scrollHeight + 25 + "px";
                pTar.width = pTar.Document.body.scrollWidth + "px";
            }
        }
        if (Sys.firefox) {
            pTar.height = pTar.contentDocument.body.offsetHeight + 15 + "px";
            pTar.width = pTar.contentDocument.body.scrollWidth + "px";
        }
        if (Sys.chrome) {
            pTar.height = pTar.contentDocument.body.offsetHeight;
            pTar.width = pTar.contentDocument.body.scrollWidth;
        }
        if (Sys.opera) {
            pTar.height = pTar.contentDocument.body.offsetHeight;
            pTar.width = pTar.contentDocument.body.scrollWidth;
        }
        if (Sys.safari) {
            if (pTar.contentDocument.body.offsetHeight <= '186') {
                pTar.height = pTar.contentDocument.body.offsetHeight + 10;
            } else {
                pTar.height = pTar.contentDocument.body.offsetHeight;
            }
            pTar.width = pTar.contentDocument.body.scrollWidth;
        }
    }

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宜川县| 青神县| 增城市| 三江| 赞皇县| 太原市| 二连浩特市| 淮北市| 门头沟区| 乐都县| 阜城县| 溧水县| 邹城市| 江门市| 卓资县| 怀仁县| 兴国县| 富阳市| 吕梁市| 玉龙| 鄂州市| 富阳市| 冷水江市| 武强县| 邯郸县| 思茅市| 伊通| 和龙市| 永泰县| 邵阳县| 尉氏县| 固阳县| 通海县| 天等县| 吴川市| 施甸县| 岑溪市| 若羌县| 盐城市| 盐城市| 太保市|