I am trying to load the following html inside a UIWebView.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <body> <div id="fb-root"></div> <script> window.fbAsyncInit = function() { FB.init({ appId : 'myAppId', status : true, xfbml : true }); FB.Event.subscribe("xfbml.render", function(response) { FB.Canvas.setSize(); }); }; (function(d, s, id){ var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "http://connect.facebook.net/en_US/all.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script> <div class="fb-comments" data-href="http://www.google.com/" data-num-posts="10"></div> </body> </html>
In the browser, it correctly displays the comment window, and FB.Canvas.setSize () resizes the height accordingly (without it, the iframe interval height is set to 160).
This setSize () function does nothing inside the UIWebView, probably because the URL scheme is not http or https. I cannot verify this because the Safari debugger does not show me the message "Unsafe Javascript attempt".
I load UIWebView with loadHTMLString: baseURL:
How can I get facebook comment box for corresponding height?
Side notes:
Similar question: Unable to load full-featured Facebook comment plugins inside iOS UIWebView
Facebook cheat all.js I found this code inside the comment function (if you are looking for "sdk.XFBML.Comments") which sets the height
getSize: function() { if (this._attr.mobile) return { width: '100%', height: 160 }; return { width: this._attr.width, height: 160 };
source share