2012-03-07 29 views
1
<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> 

我想擴大我的畫布頁面寬度爲1200,但我的代碼似乎無法工作,因爲畫布寬度仍然是760(我沒有設定「畫布寬度」來液體在畫布設置),誰能告訴我我犯了什麼錯誤?我的代碼如下: -FB.Canvas.setSize不工作

謝謝大家,祝你有美好的一天。

回答

0

我認爲setSize已被棄用,請嘗試使用autoGrow並使用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); 
    }; 

然後你可以在你的css中設置你的身體寬度爲1200。

+0

感謝本,我現在就來試試吧。 – 2012-03-07 07:36:37

+0

我試過你的編碼,但結果仍然是一樣的......是我在編碼之前沒做過的任何事情嗎? – 2012-03-07 07:44:56

+0

您還必須在應用程序設置(高級)下將畫布寬度和高度設置爲「流暢」。 您還可以在autoGrow運行之前增加超時 - 如果您的頁面需要很長時間才能加載。您可以傳遞等待的毫秒數 - 默認情況下爲100. 例如:FB.Canvas.setAutoGrow(200); – Ben 2012-03-07 11:55:27

0

許多人忘了建立自己的安全https:

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

檢查您的網址,以防萬一