I'm creating a Facebook canvas application to be loaded in the iframe.
The height of the content could differ because of the dynamic data loaded there and cannot be set beforehand. The canvas should resize itself to fit the content automatically. I need to get rid of the vertical scrollbar in the iframe in all modern browsers.
I set "Canvas Height: Fixed at 800px" in the advanced settings of the application and use the solution with FB.Canvas.setSize() that is recommended:
<body>
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function () {
FB.init({
appId: 'NNNN', // My App ID is placed here
status: true,
cookie: true,
xfbml: true
});
FB.Canvas.setSize();
FB.Canvas.setAutoGrow(7);
};
function sizeChangeCallback() {
FB.Canvas.setSize();
}
// Load the SDK Asynchronously
(function (d) {
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) { return; }
js = d.createElement('script'); js.id = id; js.async = true;
js.src = d.location.protocol + "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
} (document));
...
</script>
...
</body>
It works fine in Firefox, MSIE 9, and Opera. But it does not work in WebKit browsers on Windows: Safari and Chrome.
Safari displays the following code for the canvas iframe:
<iframe class="canvas_iframe_util noresize" frameborder="0" scrolling="no" id="iframe_canvas" name="iframe_canvas" src='javascript:""' height="800" style="height: 800px; overflow-y: hidden; "></iframe>
What am I doing wrong? Is it possible to make it work in Firefox, MSIE, Opera, Safari, and Chrome at the same time?