今天我浪費了四個小時,幾個頭髮試圖解決這個問題,但失敗了。如何使用新的Facebook JavaScript SDK關閉(隱藏)FBML對話框?
我們使用facebook.connect
授權我們網站上的用戶並執行各種操作。其中一個動作應該會觸發fbml:dialog
,我決定使用新的JavaScript SDK。這裏的功能我用:
function popupModalWindow(cat) {
var oldSize = FB.UIServer.Methods["fbml.dialog"].size;
FB.UIServer.Methods["fbml.dialog"].size = {width: 402, height: 112};
//FB.UIServer.id = FB.UIServer._active[id];
var messages = {
interesting: '<p>By submitting my entry, I confirm that I have obtained permission from the persons whose picture and/or voice appears in my entry for use and publication in this contest as outlined in the Official Rules [link]</p>'
};
// alert(messages[cat]);
FB.ui(
{
method: 'fbml.dialog',
//id: 'ololo',
display: 'dialog',
width: 402,
height: 112, /**/ //Should work that way according to the API reference
size : {width: 402, height: 112},
fbml: '<link rel="stylesheet" href="http://rentatext.mygrate.biz/styles.css"/><div class="modal-white" style="width: 402px;">'+
'<h6>User Agreement</h6>'+
'<fb:js-string var="oloe">document.getElementsByTagName("iframe")[0].id;</fb:js-string>'+
'<div class="inner">'+messages[cat]+' <a class="fb-close" onclick="FB.UIServer._active[oloe].close()">i agree</a></div></div>'
,
},
function() {
alert(1);
}
);
console.debug(FB.UIServer);
}
不幸的是,設計師灰色背景使這些模態窗口和一些用戶可能沒有注意到,在對話框的右上角的默認的「關閉」按鈕。我需要的是將一個事件綁定到將關閉此對話框的某個自定義元素。我嘗試了不同的方法,但都沒有工作。
當我點擊a.fb-close
與onclick事件處理程序時,最新的一個拋出「a138033292903816_FB未定義」。也許我錯過了一些東西,我搜索了很多,但沒有運氣。