facebook javascript SDK:FB.Canvas.setAutoResize iFrame不能正常工作? [英] facebook javascript SDK: FB.Canvas.setAutoResize iFrame not working?

查看:92
本文介绍了facebook javascript SDK:FB.Canvas.setAutoResize iFrame不能正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用ruby / rails和facebooker(iframe应用程序)构建了一个facebook应用程序,目前仍然使用FB.Canvas.setAutoResize,在某些情况下似乎失败了。使用来自facebook开发人员文档的示例(请参阅 http://developers.facebook.com/docs/参考/ javascript / )。一旦你进入一个高于800px的页面,autoresize就会失败 - 所以说,只要画布变大,它就会起作用,而不是当它变小时。任何人有线索或解决方法?

we built a facebook application with ruby/rails and facebooker (iframe application) and are currently stuck with the FB.Canvas.setAutoResize which seems to fail in some cases. using the example from facebook developer docs ( see http://developers.facebook.com/docs/reference/javascript/ ). the autoresize fails once you enter a page which is higher than 800px - so to say, it just works as long as the canvas gets bigger, not when it gets smaller. anyone has a clue or maybe a workaround?

这里是调整大小的代码片段

here is the resizing code piece

<div id="fb-root" style="width:1px;height:1px;position:absolute;"></div> 
<script type="text/javascript"> 
  window.fbAsyncInit = function() {
    FB.init({appId: '126342024064822', status: true, cookie: true, xfbml: true});
    FB.Canvas.setAutoResize(true,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>

我非常感谢任何评论或提示,因为我正在扭转这个问题或更多现在比一天。

i am very thankful for any comments or hints, since i am twisting my head around this one for more than a day now.

推荐答案

要确保的一些关键事项在应用程序设置中设置:

Some key things to make sure are set in the application settings:


  1. 画布设置 - >渲染方法= iFrame

  2. 画布设置 - > iFrame尺寸=可调整大小

  3. 迁移 - >新SDK =已启用

接下来通过添加超时来调整代码( 250似乎效果最好,但你可能想进行实验)。我在FF3.6和IE7 +中测试了这个。在IE浏览器中有一个垂直滚动条的瞬间闪现,我仍在尝试修复。

Next adjust your code by adding a timeout (250 seems to work best, but you may want to experiment futther). I've tested this in FF3.6 and IE7+. In IE there is a momentary flash of the vertical scrollbar which I'm still trying to fix.

<div id="fb-root"></div> 
<script type="text/javascript"> 
  window.fbAsyncInit = function() {
    FB.init({appId: '12345678910', status: true, cookie: true, xfbml: true});
  window.setTimeout(function() {
    FB.Canvas.setAutoResize();
  }, 250);
  };
  (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 javascript SDK:FB.Canvas.setAutoResize iFrame不能正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆