Quantcast
Channel: HAPPY*TRAP » Facebook
Viewing all articles
Browse latest Browse all 10

Facebookアプリ iframeの高さを変更する

$
0
0
Facebookアプリ iframeの高さを変更する

2012年09月18日追記
現在、FB.Canvas.setAutoResize();は廃止されていますので、代わりに、FB.Canvas.setAutoGrow();をお使いください。


Facebookアプリのiframeの高さを変更する方法です。
JavaScript SDKのsetAutoResizeメソッドを使います。

※サンプルの作成には、以下のサイトを参考にさせていただきました。

iframeの高さを自動調節する

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<div id="fb-root"></div>
<script type="text/javascript">
<!--
window.fbAsyncInit = function() {
    FB.init({
        appId: 'Your appID',
        status: true,
        cookie: true,
        xfbml: true
    });
    // iframeの高さを自動調節
    FB.Canvas.setAutoResize();
};
(function() {
    var e = document.createElement('script');
    e.type = 'text/javascript';
    e.src = document.location.protocol + '//connect.facebook.net/ja_JP/all.js';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
 }());
//-->
</script>

iframeの高さを指定する

高さを指定したい場合はsetSizeが利用できます。
1
FB.Canvas.setSize({ width: 640, height: 480 });


Viewing all articles
Browse latest Browse all 10

Trending Articles