Facebook JavaScript SDK FB.Canvas.setSize and setAutoGrow not working in IE7/8

facebookfacebook-graph-apifacebook-javascript-sdkinternet-explorer-7internet-explorer-8

Currently I'm testing a Facebook tab page. I am using the JavaScript SDK with the recommended async init method:

window.fbAsyncInit = function() {
        FB.init({
          appId      : app_id,
          status     : true, 
          cookie     : true, 
          oauth      : true,
          xfbml      : true 
        });


        FB.getLoginStatus( loginStatus );
        FB.Canvas.setAutoGrow( );
        FB.Canvas.setSize( {height: 1200 });


     };

     (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));

I am having issues in IE7/8 where the setAutoGrow and setSize are not responding. My tab page is NOT resizing to the full content at all. Instead in IE console I am getting this error whenever I call either setAutoGrow or setSize:

SCRIPT438: Object doesn't support this property or method all.js, line 15 character 3916

I tested this in Chrome/FF/IE9 PC/MAC and all works fine, only IE7/8 are giving me these issues. Anyone know if these are known bugs with FB's JS SDK or am I doing something wrong?

Best Answer

<script type="text/javascript">
    FB.Canvas.setSize({ width: 520, height: 1400 });
    window.fbAsyncInit = function () {
        FB.Canvas.setAutoResize();
    }
</script>

Use this and put it right before closing body tag.

also make sure you have this markup inside the body tags also:

<div id="fb-root"></div>
<script type="text/javascript" src="//connect.facebook.net/en_US/all.js"></script>
Related Topic