动态增加 iframe 高度

Increase iframe height dynamically

本文关键字:高度 iframe 增加 动态      更新时间:2023-09-26

我正在尝试将游戏集成到我的phpfox社交网络中。它附带的代码是由第三方提供的,如下所示

<script type="text/javascript">
            $(document).ready(function(){               
                $('body').append('<iframe id="crossdomain_frame" src="<?php echo APP_URL; ?>static/crossdomain.php?height=' + document.body.scrollHeight + '&nocache=' + Math.random() + '" height="0" width="0" frameborder="0"></iframe>');
            });     
        </script>

在设置东西时,框架的高度被搞砸了。我不明白如何增加高度。在加载页面源代码时查看页面源代码时,我发现<iframe>在页面中甚至没有heightwidth属性。有人可以帮忙吗?

附言您可以通过打开 http://social.techbreeze.in/index.php?do=/apps/4/candy-rush/并使用您的Facebook帐户登录来亲自查看页面的外观。

在将

iframe 附加到正文后,您可以使用 jquery 设置 iframe 的高度。

$(document).ready(function(){               
       $('body').append('<iframe id="crossdomain_frame" src="<?php echo APP_URL; ?>static/crossdomain.php?height=' + document.body.scrollHeight + '&nocache=' + Math.random() + '" height="0" width="0" frameborder="0"></iframe>');
       $('#crossdomain_frame').css('height', $(window).height()+'px');
});