您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

JavaScript自动设置IFrame高度

2025/3/19 5:10:00发布26次查看
[javascript]
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;
        }
    }
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product