0

如何设置来自谷歌网站的页面标签内容的高度?它工作得很好,我只是希望垂直滚动条不要长于实际的 facebook 页面大小。

我现在使用的代码

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
  // init the FB JS SDK
  FB.init({
    appId      : '576155032405795',                        // App ID from the app dashboard

  });

  FB.Canvas.setAutoGrow();
};

// Load the SDK asynchronously
(function(d, s, id){
 var js, fjs = d.getElementsByTagName(s)[0];
 if (d.getElementById(id)) {return;}
 js = d.createElement(s); js.id = id;
 js.src = "//connect.facebook.net/en_US/all.js";
 fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
4

1 回答 1

0

You may want to look into the setAutoGrow() or setSize() functions of JavaScript SDK. Both may help you but you will have to judge which one to use, from the setAutoGrow()'s documentation

This function is useful if you know your content will change size, but you don't know when. There will be a slight delay, so if you know when your content changes size, you should call setSize yourself (and save your user's CPU cycles).

and from setSize()'s documentation

Call this whenever you need a resize. This usually means, once after pageload, and whenever your content size changes.

So you need to judge accordingly.

Edit

I would like you to use setAutoGrow() function in your code. You will need to put this code in the page that is been rendered within the Page Tab. And as you have mentioned that is your content is retrieved from page within your Google sites, then this is where you would be required to add the code.

You will have to insert the following code within your page just after the body opening tag

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
  // init the FB JS SDK
  FB.init({
    appId      : 'YOUR_APP_ID',                        // App ID from the app dashboard
    channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel file for x-domain comms
  });

  FB.Canvas.setAutoGrow();
};

// Load the SDK asynchronously
(function(d, s, id){
 var js, fjs = d.getElementsByTagName(s)[0];
 if (d.getElementById(id)) {return;}
 js = d.createElement(s); js.id = id;
 js.src = "//connect.facebook.net/en_US/all.js";
 fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>

Here the channel.html will contain just the following line of code

<script src="//connect.facebook.net/en_US/all.js"></script>
于 2013-05-12T07:27:42.477 回答