爱编程
多层iframe嵌套,滚动条显示的处理
2015-3-23 Jessie


页面a:



<div>



     <iframe id="iframeIda"   width="100%" align="center"   height="this.height=iframeIda.document.body.scrollHeight"  frameborder="0"                 scrolling="auto" src="页面b"></iframe>



</div>



页面b:



<div>test</div>



<div>



    <iframe id="iframeIdb"   width="100%" align="center"   onload="setWinHeight()"  frameborder="0" scrolling="auto" src="页面c">



    </iframe>



</div>



b页面的js



 <script type="text/javascript">

            $(document).ready(function(){

                $(window).resize(function(){setWinHeight();});

            });

            function setWinHeight() {

                var obj=document.getElementById("iframeIdb");

                var temp=document.body.scrollHeight;

                var temp2=document.documentElement.clientHeight;

                obj.style.height = temp2 + 'px';

                parent.document.getElementsByTagName("iframe")[0].style.height=temp+'px';

            }

        </script>







页面c:就是平时的一个页面,不包含iframe。