iframe大小控制方法

1//js函数iframe的高度自动根据引用页面的高度变化
 2<script type="text/javascript">  
 3    function SetWinHeight(obj)
 4    {
 5        var win=obj;
 6        if (document.getElementById)
 7        {
 8            if (win && !window.opera)
 9            {
10                if (win.contentDocument && win.contentDocument.body.offsetHeight) 
11                    win.style.height = win.contentDocument.body.offsetHeight;
12                else if(win.Document && win.Document.body.scrollHeight)
13                    win.style.height = win.Document.body.scrollHeight;
14            }

15
16        }

17    }

18
19//引用
20<iframe width="100%" frameborder="0" id="ifr" name="ifr" src="mindex.html" onload="SetWinHeight(this)" scrolling="no"></iframe> 
0
0
(请您对文章做出评价)

posted on 2010-03-30 11:26  Gsun  阅读(453)  评论(0编辑  收藏  举报

导航