javascript - iframe height adaptive problem
阿神
阿神 2017-05-19 10:38:27
0
2
562

The following is the content of the main page:

        <script type="text/javascript">
            function changeFrameHeight(){
                var ifm= document.getElementById("iframepage");
                ifm.height=document.body.clientHeight + 50;
            }
            window.onresize=function(){  
                 changeFrameHeight();
            } 
        </script>
        <p id="tt">
            <p title="首页">
                <iframe src="page/home.html" id="iframepage"  onload="changeFrameHeight()"  style="width:100%;" scrolling="no" frameborder="0"></iframe>
            </p>
        </p>

When the page is zoomed out, all the contents of home.html cannot be displayed. How should I change it?

阿神
阿神

闭关修行中......

reply all(2)
给我你的怀抱

<script type="text/javascript">

function changeFrameHeight(){
  setTimeout(function(){
    var iFrameID = document.getElementById('iframepage');
    if(iFrameID) {
      iFrameID.height = "";
      iFrameID.height = iFrameID.contentWindow.document.body.scrollHeight + "px";
    }   
  },300)
}
window.onresize=function(){  
  changeFrameHeight();
} 

</script>

巴扎黑

Then you have to write the adaptation of the window size in the home page

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template