douzi7219 2015-01-30 03:39
浏览 35
已采纳

JS - Iframe高度调整大小

I have this

 <script>
     var calcHeight = function() {
       $('#iframe').height($(window).height());
     };
     $(document).ready(function() {
       calcHeight();
     });

     $(window).resize(function() {
       calcHeight();
     }).load(function() {
       calcHeight() ;
     }); </script>

The above JS just resizes the height. How to I edit the above JS and add to the calculated height 10px?

For example if the JS calculates 700px, I need to have the height as 710px.

  • 写回答

2条回答 默认 最新

  • dongmu7335 2015-01-30 03:54
    关注

    Maybe something like this

    <script>
     var calcHeight = function() {
       $('#iframe').height(10 + +$(window).height());
     };
     $(document).ready(function() {
       calcHeight();
     });
    
     $(window).resize(function() {
       calcHeight();
     }).load(function() {
       calcHeight() ;
     }); </script>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?