我正在構建一個GWT應用程序,並試圖在某些地方動態添加Facebook評論框。這工作正常,除了facebook SDK沒有正確計算高度。它始終將其設置爲160px。fb:評論是設置錯誤的高度(削減評論一半)
這意味着即使有多條評論(即它明顯減半),也只有第一條評論的一半可見。如果我在GWT之外使用相同的代碼,它可以正常工作(即高度計算正確)。
有誰知道facebook SDK如何計算盒子的高度?還有什麼我可以嘗試?
細節:
我初始化的Facebook SDK如下:
public static native void initFacebookSDK()
/*-{
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : '<my-app-id>', // App ID from the App Dashboard
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File for x-domain communication
status : true, // check the login status upon init?
cookie : true, // set sessions cookies to allow your server to access the session?
xfbml : true
// parse XFBML tags on this page?
});
// Additional initialization code such as adding Event Listeners goes here
};
// Load the SDK's source Asynchronously
(function(d, debug) {
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 = "//connect.facebook.net/en_US/all"
+ (debug ? "/debug" : "") + ".js";
ref.parentNode.insertBefore(js, ref);
}(document, false));
}-*/;
我添加了DIV如下:
//_root is a vertical panel
_root.add(new HTML("<div id=\"mydiv\"></div>"));
,然後我填充格狀這個:
public static native void showComments(String currentUrl_)
/*-{
var mydiv = $doc.getElementById('mydiv');
mydiv.innerHTML = "<fb:comments href='" + currentUrl_
+ "' num_posts='5' width='422'></fb:comments>";
FB.XFBML.parse(mydiv);
}-*/;
的問題是,Facebook的SDK始終填充用DIV如下:
<span style="height: 160px; width: 422px;">
<iframe ...>...</iframe>
</span>
而如果我不使用GWT,高度參數修改正確,如:
<span style="height: 1469px; width: 422px;">
<iframe ...>...</iframe>
</span>
希望有人能幫忙。