javascript Facebook iframe FB.Canvas.setAutoGrow 在初始加载后不会自动增长?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9197411/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 05:54:30  来源:igfitidea点击:

Facebook iframe FB.Canvas.setAutoGrow does not auto grow after initial load?

javascriptfacebookfacebook-javascript-sdkfacebook-iframe

提问by Joshc

I have been building a facebook tab using html and css and facebooks javascript SDK.

我一直在使用 html 和 css 以及 facebooks javascript SDK 构建一个 facebook 选项卡。

I having problems with the iframe resizing to the size of the content.

我在将 iframe 调整为内容大小时遇到​​问题。

I've managed to get it to work on initial load which is cool, using this below script...

我已经设法让它在初始负载上工作,这很酷,使用下面的脚本......

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#">

-

——

<div id="fb-root"></div>
<script type="text/javascript">
  window.fbAsyncInit = function() {
    FB.init({
      appId      : '00000000000000', // App ID
      channelUrl : '//www.mywebsite.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
    });

    FB.Canvas.setAutoGrow();

  };

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

and my channel.html looks like this...

我的 channel.html 看起来像这样......

<?php
 $cache_expire = 60*60*24*365;
 header("Pragma: public");
 header("Cache-Control: max-age=".$cache_expire);
 header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$cache_expire) . ' GMT');
 ?>
 <script src="//connect.facebook.net/en_US/all.js"></script>


Like I said the initial page load resizing is perfect, but as I navigate around the iframe, it does not autogrow to my content.


就像我说的初始页面加载调整大小是完美的,但是当我在 iframe 中导航时,它不会自动增长到我的内容。

Can anyone advise as I'm very new to this facebook iframe biz.

任何人都可以提供建议,因为我对这个 facebook iframe biz 很陌生。

Thanks in advance

提前致谢

回答by Sándor Tóth

Please check these:

请检查这些:

A, Do you have <!DOCTYPE html>at the top of the HTML?

A、你有<!DOCTYPE html>顶部的HTML吗?

B, Do your app generates valid HTML? Here is the validator tool: http://validator.w3.org/

B、您的应用是否生成有效的 HTML?这是验证器工具:http: //validator.w3.org/