【问题标题】:Scroll bars in Facebook iframe app... againFacebook iframe 应用程序中的滚动条...再次
【发布时间】:2012-10-23 23:06:46
【问题描述】:

我会做同样的事情两次,结果却不同!!!
我在这里开了一家商店,效果很好
应用链接:https://www.facebook.com/stlocarina/app_365351356883221

以及松开滚动条的代码:

     <div id="fb-root"></div>
    <script src="https://connect.facebook.net/en_US/all.js"></script>
    <script>
  window.fbAsyncInit = function() {
    FB.init({
      appId : '365351356xxxxxx', //Your facebook APP here
      cookie : true // enable cookies to allow the server to access the session
    });
  }

  window.onload = function() {
    FB.Canvas.setAutoGrow(91);
  }
</script>

在这里尝试相同的代码后,我有滚动条。

FB 中的应用链接:https://www.facebook.com/AshevilleAleTrail/app_420678397982002

这是我用来尝试自动调整大小的代码(那不是很有效):

    <div id="fb-root"></div>
<script type="text/javascript">
  window.fbAsyncInit = function() {
    FB.init({
    appId      : '420678397xxxxxx', // App ID
      channelUrl : '//www.publicityresultshosting.com//channel.html', // Channel File
  status     : true, // check login status
  cookie     : true, // enable cookies to allow the server to access the session
  xfbml      : true  // parse XFBML
    });

  };

 // Load the SDK Asynchronously
  (function(d){
 var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
 js = d.createElement('script'); js.id = id; js.async = true;
 js.src = "//connect.facebook.net/en_US/all.js";
 d.getElementsByTagName('head')[0].appendChild(js);
   }(document));
</script>


<script type="text/javascript">
    window.fbAsyncInit = function() {
        FB.init({appId: '420678397xxxxxx', status: true, cookie: true, xfbml: true});
        FB_RequireFeatures(["CanvasUtil"], function(){ FB.XdComm.Server.init("xd_receiver.htm");
            FB.CanvasClient.startTimerToSizeToContent(); });
           FB.Canvas.setAutoResize(true,500);
    };
    (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>

关于如何解决这个问题的任何想法?

【问题讨论】:

标签: facebook iframe facebook-iframe


【解决方案1】:

你必须设置大小,页面加载后你可以在回调中运行setAutoGrow()

FB.Canvas.setSize({ width: 810, height: 950 });

FB.Canvas.setDoneLoading( function(response) {
    FB.Canvas.setAutoGrow();
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-21
    • 2011-05-10
    • 2011-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-20
    相关资源
    最近更新 更多