I have this code:
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.Canvas.setSize({ height: 6000 });
}
window.fbAsyncInit();
</script>
This resizes my iFrame correctly about 50% of the time. The other 50% of the time it does not resize and the following error appears on my console:
Uncaught ReferenceError: FB is not defined
window.fbAsyncInit:122
(anonymous function)
At first I thought this was an error with how I embedded the Facebook Javascript SDK, but then why does it work sometimes and not at other times?
Might be "race condition" of some sort, so just wait until FB is defined:
When FB won't be defined it will keep checking every 10 milliseconds, until it's defined.