让iframe自动跟着屏幕调整大小

    <script type="text/javascript">
        
var resizeTimer = null;
        
function doResize() {
            
var h = document.documentElement.clientHeight - 220;
            
if (h > 0)
                $(
"#mainframe").css("height", h);
            resizeTimer 
= null;
        }

        
var t = document.documentElement.clientWidth;
        
var setHeight = function () {
            
if (t != document.documentElement.clientWidth) {
                t 
= document.documentElement.clientWidth;
                
if (resizeTimer == null) {
                    resizeTimer 
= setTimeout("doResize()"1000); //控制调用方法的时间间隔
                }
            }
        }

        window.onresize 
= setHeight;
        doResize();
    
</script>

 

posted on 2010-06-02 18:01  廖勇军  阅读(310)  评论(0编辑  收藏  举报

导航