{"id":251,"date":"2012-06-12T21:26:21","date_gmt":"2012-06-13T02:26:21","guid":{"rendered":"http:\/\/www.marcblase.com\/blog\/?p=251"},"modified":"2012-06-14T14:20:58","modified_gmt":"2012-06-14T19:20:58","slug":"removing-those-bothersome-facebook-canvas-app-scrollbars","status":"publish","type":"post","link":"https:\/\/ma.rcbla.se\/blog\/2012\/06\/removing-those-bothersome-facebook-canvas-app-scrollbars\/","title":{"rendered":"Removing those bothersome Facebook Canvas app scrollbars"},"content":{"rendered":"<p>Just did my first app since Facebook has forced timeline on everyone.<\/p>\n<p>PROS: Full width page tabs.<\/p>\n<p>CONS: Can&#8217;t make the page open on a page tab (AFAIK). Scrollbars if your page tab markup extends to 810px.<\/p>\n<p>To fix the scrollbar issue you have to load the FB SDK and make a call to the FB.Canvas.setAutoGrow() function. This will push the iframe to the bounds of your markup, which if sized correctly, will make the scrollbars disappear. <\/p>\n<p>Here&#8217;s the code:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;div id=&quot;fb-root&quot;&gt;&lt;\/div&gt;\r\n&lt;script&gt;\r\n  window.fbAsyncInit = function() {\r\n    FB.init({\r\n      appId      : 'YOUR_APP_ID', \/\/ App ID\r\n      channelUrl : 'YOUR_APP_URL\/channel.php', \/\/ Channel File\r\n      status     : true, \/\/ check login status\r\n      cookie     : true, \/\/ enable cookies to allow the server to access the session\r\n      xfbml      : true  \/\/ parse XFBML\r\n    });\r\n\r\n    \/\/ Additional initialization code here\r\n\t\/\/ FB.Canvas.setAutoResize();\r\n    FB.Canvas.setAutoGrow();\r\n  };\r\n\r\n  \/\/ Load the SDK Asynchronously\r\n  (function(d){\r\n     var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}\r\n     js = d.createElement('script'); js.id = id; js.async = true;\r\n     js.src = &quot;\/\/connect.facebook.net\/en_US\/all.js&quot;;\r\n     d.getElementsByTagName('head')&#x5B;0].appendChild(js);\r\n   }(document));\r\n&lt;\/script&gt;\r\n<\/pre>\n<p>Include the code above just after the opening body tag. You&#8217;ll also need to setup a channel file, as referenced in the code above via the &#8220;channelUrl&#8221; option. According to the FB docs you want this to cache and it&#8217;s very important that the protocols match, so make them protocol independent. Eg. &#8220;\/\/www.website.com\/channel.php&#8221;. <\/p>\n<p>Here&#8217;s the code for the channel file:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n &lt;?php\r\n $cache_expire = 60*60*24*365;\r\n header(&quot;Pragma: public&quot;);\r\n header(&quot;Cache-Control: max-age=&quot;.$cache_expire);\r\n header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$cache_expire) . ' GMT');\r\n ?&gt;\r\n &lt;script src=&quot;\/\/connect.facebook.net\/en_US\/all.js&quot;&gt;&lt;\/script&gt;\r\n<\/pre>\n<p>Also include <code>overflow:hidden;<\/code> in your CSS for the body tag so that there is no flash of scroll bars while we are waiting for things to happen when the page loads.<\/p>\n<p><small>Reference: <a href=\"https:\/\/developers.facebook.com\/docs\/reference\/javascript\/\">Facebook JavaScript SDK<\/a><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just did my first app since Facebook has forced timeline on everyone. PROS: Full width page tabs. CONS: Can&#8217;t make the page open on a page tab (AFAIK). Scrollbars if your page tab markup extends to 810px. To fix the scrollbar issue you have to load the FB SDK and make a call to the [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,3],"tags":[],"class_list":["post-251","post","type-post","status-publish","format-standard","hentry","category-coding","category-discoveries"],"_links":{"self":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts\/251","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/comments?post=251"}],"version-history":[{"count":9,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts\/251\/revisions"}],"predecessor-version":[{"id":270,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts\/251\/revisions\/270"}],"wp:attachment":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/media?parent=251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/categories?post=251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/tags?post=251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}