風吟月
風吟月

Reputation: 243

FB.Canvas.setSize is not working

<html>
 <head>
   <title>Fluid Width HTML Example </title>
 </head>

 <body style="margin:0; padding:0; border:0; background-color:#000000;width:1500px">

    <div id="fb-root"></div>
            <script>
              window.fbAsyncInit = function() {
                 FB.init({
                   appId  : 'xxxxxxxxxxxxx',
                  status : true, // check login status
                  cookie : true, // enable cookies to allow the server to access the session
                  xfbml  : true,  // parse XFBML
                   // channelUrl  : 'http://www.yourdomain.com/channel.html', // Custom Channel URL
                   oauth : true //enables OAuth 2.0
                });

                FB.Canvas.setSize({width:1200});

               };

              (function() {
                var e = document.createElement('script');
                e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
                e.async = true;
                document.getElementById('fb-root').appendChild(e);
              }());
            </script>

     <div id="allContent" style="background-color: #0000FF; height:50%;width:100%">
        <div id="output" style="color: #FFFFFF;" />
     </div>

  </body>
</html>

I would like to expand my canvas page width to 1200, but my code seems fails to work, because the canvas width is still 760 (I did set 'Canvas Width' to fluid in Canvas setting), can anyone tell me what mistakes I'd made? my code is as below:-

Thanks everyone, and have a nice day.

Upvotes: 1

Views: 2206

Answers (3)

test
test

Reputation: 2466

Most people forget to set up their secure https:

Page Tab URL:            http://...
Secure Page Tab URL:     https://...

Check your url, just in case

Upvotes: 0

Justin
Justin

Reputation: 11

SetSize hasn't been deprecated but SetAutosize has.

http://developers.facebook.com/docs/reference/javascript/FB.Canvas.setAutoGrow/

There does however seem to be a bug where SetSize and SetAutoGrow isn't working properly, details can be found here: http://developers.facebook.com/bugs/322561887802154. It is all rather frustrating!

Upvotes: 1

Ben
Ben

Reputation: 2651

I think that setSize has been deprecated, try using autoGrow and setting the width of you page using CSS.

window.fbAsyncInit = function () {
     FB.init({
         appId  : 'xxxxxxxxxxxxx',
         status : true, // check login status
         cookie : true, // enable cookies to allow the server to access the session
         xfbml  : true,  // parse XFBML
      // channelUrl  : 'http://www.yourdomain.com/channel.html', // Custom Channel URL
         oauth : true //enables OAuth 2.0
      });

        FB.Canvas.setAutoGrow(true);
    };

Then You can set your body width to 1200 in your css.

Upvotes: 0

Related Questions