对Iframe和图表设置高度的优质代码

 1 //对Iframe和图表设置高度
 2     function f() {
 3         parent.window.setWinHeight(parent.window.document.getElementById("frame_${queryCategory}"));
 4     }
 5     var win_height, interval, cnt = 0;
 6     function dif() {
 7         var cur_height = document.body.offsetHeight;
 8         if (cur_height != win_height || cnt > 10) {
 9             clearInterval(interval);
10             f();
11         }
12         cnt++;
13     }
14     var myview = $.extend({},$.fn.datagrid.defaults.view,{
15         onBeforeRender:function(target){
16             win_height = document.body.offsetHeight;
17             interval = setInterval("dif()",1000);
18         }
19     });
    // 图表转换方法:用于切换图与表。
    var init = false;
    function toggle(){
        if ($("#container").is(":hidden")) {
            $("#container").show();
            $("#refshbtn").show();
            $("#prm_div").show();
            $("#report_ui").hide();
            $("#tb").hide();
            updateChartData();
            f();
        }else {
            $("#container").hide();
            $("#refshbtn").hide();
            $("#prm_div").hide();
            $("#report_ui").show();
            $("#tb").show();
            if (!init) {
                $('#tt').datagrid({view:myview,rownumbers:true,
                    singleSelect:true,
                    toolbar: '#tb',
                    onClickRow: onClickRow});
                init = true;
            }
            $("#tt").datagrid('resize', {
                 $(document.body)[0].clientWidth
            });
            f();
        }
    }
_____________________________________________________________________________________________________ ***************************************************************************************************************** ===坚持、奋斗***今天的努力只为更好的明天***奋斗、坚持===********************** ==========================================================================================
原文地址:https://www.cnblogs.com/mlloc-clove/p/3880944.html