内容根据窗口大小自适应

/** *******************自适应 start************************* */

var isIE = !!window.ActiveXObject;
var isIE6 = isIE && !window.XMLHttpRequest;
var isIE8 = isIE && !!document.documentMode;
var isIE7 = isIE && !isIE6 && !isIE8;
var isResize = true;
$(window).resize(function() {
    var ss = getPageSize();

    /* var jqgirdwidth = $(document.body).width(); */
    if (isIE) {
        $(".widget-body").height(ss.WinH - $(".widget-header").height() - 10);
        $(".widget-main").height(ss.WinH - $(".widget-header").height()-$(".toolbar").height() - 12);
    } else {
        $(".widget-body").height(ss.WinH - $(".widget-header").height() - 10);
        $(".widget-main").height(ss.WinH - $(".widget-header").height()-$(".toolbar").height() - 12);
    }
});

function getPageSize() {
    // http://www.blabla.cn/js_kb/javascript_pagesize_windowsize_scrollbar.html
    var winW, winH;
    if (window.innerHeight) {// all except IE
        winW = window.innerWidth;
        winH = window.innerHeight;
    } else if (document.documentElement
            && document.documentElement.clientHeight) {// IE 6 Strict Mode
        winW = document.documentElement.clientWidth;
        winH = document.documentElement.clientHeight;
    } else if (document.body) { // other
        winW = document.body.clientWidth;
        winH = document.body.clientHeight;
    } // for small pages with total size less then the viewport
    return {
        WinW : winW,
        WinH : winH
    };
}

$(function() {
    var ss = getPageSize();
    /* $("#grid-table").setGridWidth(ss.winW); */
    $(".widget-body").height(ss.WinH - $(".widget-header").height() - 10);
    $(".widget-main").height(ss.WinH - $(".widget-header").height()-$(".toolbar").height() - 12);
});

/** *******************自适应 end************************* */

猜你喜欢

转载自blog.csdn.net/huanfengzhiqiu/article/details/80910754
今日推荐