jQuery iframe 高度自适应

 

必须在所有DOM元素加载完毕之前调用,否则不起作用

$("#rightPanel").load(function() {
	$(this).height($(this).contents().height());	
});

 

 

根据实际情况进行了一下改良,代码如下:

<script type="text/javascript">
    $(function(){
        $("#workArea").load(function(){    
            var height = $(this).contents().find("#box").height() + 40;
            //这样给以一个最小高度
            $(this).height( height < 400 ? 400 : height );
        });
    });
</script>

 

 

你可能感兴趣的:(jquery)