gpt4 book ai didi

javascript - 如何使用新的 Facebook JavaScript SDK 关闭( Conceal )FBML 对话框?

转载 作者:行者123 更新时间:2023-11-29 15:05:33 25 4
gpt4 key购买 nike

我今天浪费了四个小时和几根头发试图解决这个问题但失败了。

我们使用 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);
}

不幸的是,设计者将这些模态窗口制作成灰色背景,一些用户可能没有注意到对话框右上角默认的“关闭”按钮。我需要的是将一个事件绑定(bind)到一些将关闭此对话框的自定义元素。我尝试了不同的方法,但都没有奏效。

当我使用 onclick 事件处理程序单击 a.fb-close 时,最新的抛出“a138033292903816_FB 未定义”。也许我遗漏了什么,我用谷歌搜索了很多但没有运气。

最佳答案

我也有同样的问题。第二天寻找解决方案。并找到了一种方法:要关闭事件的 FB 对话框,您应该在 FB JS 可用且调用 FB.ui 的父窗口中执行以下代码:

FB.Dialog.remove(FB.Dialog._active);

因此,在您的情况下 - 请尝试在 iframe 中使用此 JS:

parent.FB.Dialog.remove(parent.FB.Dialog._active);

希望对你有帮助

关于javascript - 如何使用新的 Facebook JavaScript SDK 关闭( Conceal )FBML 对话框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3449888/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com