在Facebook iframe滚动条或页面中途剪切之间进行选择

Choosing between Facebook iframe scrollbar or page cut off halfway

本文关键字:之间 选择 行选 iframe Facebook 滚动条      更新时间:2023-09-26

我在facebook中有一个iframe选项卡。我在body标签中使用了"overflow:hidden",在我的页面底部使用了以下代码:

 <div id="fb-root"></div>
     <script type="text/javascript">  
       window.fbAsyncInit = function() {
        FB.init({
        appId : 'MY_APP_ID',
        status : true, // check login status
        cookie : true, // enable cookies to allow the server to access the session
        xfbml : true // parse XFBML
        });
        FB.Canvas.setAutoResize(100);
       };
       (function() {
        var e = document.createElement('script');
        e.async = true;
        e.src = document.location.protocol + 
         '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);   
       }());
      </script>

这将删除滚动条并调整iframe的大小。问题是,我的页面在大约800px之后被剪切(剩下大约400px)。我已经将脸书的高度设置为"流畅"。它在其他所有浏览器中都能正常工作,但在IE8中则不然。

作为一个附带问题,IE为什么仍然存在?这绝对是最糟糕的事情。无论如何,我在头上加了这个:

<!--[if IE]>
<style>
body{overflow-y:scroll;}
</style>
<![endif]-->

但这只会让我再次拥有滚动条。

FB.Canvas.setAutoResize已重命名为FB.Canvas.setAutoGrow

此外,要使用此方法,应用程序的高度需要设置为静态,而不是流体。

你也可以试试FB.Ccanvas.stSize().

我发现有时候这些方法可能有点bug,但如果你一直调用它们,Facebook的父窗口最终会收到消息。在这种情况下,你可能想尝试这样的东西:

setInterval(FB.Canvas.setSize, 500);