简体   繁体   English

动态增加iframe高度

[英]Increase iframe height dynamically

I am trying to integrate games into my phpfox social network. 我正在尝试将游戏集成到我的phpfox社交网络中。 The code that comes for it is by a 3rd party and is something like this 产生的代码是由第三方提供的,就像这样

<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>

On setting things up the height of the frame is messed up. 在设置东西时,框架的高度混乱了。 I can't understand how to increase the height. 我不明白如何增加高度。 On viewing the page source code when it loads I find that the <iframe> doesn't even have the height and width attributes in the page. 在加载页面源代码时,我发现<iframe>甚至在页面中都没有heightwidth属性。 Could any one please help? 有人可以帮忙吗?

PS you can check out for yourself what the page looks like by opening http://social.techbreeze.in/index.php?do=/apps/4/candy-rush/ and logging in using your facebook account. 附注:您可以通过打开http://social.techbreeze.in/index.php?do=/apps/4/candy-rush/并使用您的Facebook帐户登录来查看页面的外观。

You can set the height of iframe using jquery after you append iframe to body., 将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');
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM