请原谅我缺乏JavaScript知识,但是我有Facebooks FB.ui的这段代码,我想知道在按下“共享”按钮后是否可以避免最后的确认?我只想在用户按下共享后关闭弹出式窗口,而没有任何一种确认。这可能吗?如果是这样,如何修改代码?先感谢您。
FB.ui(
{
method: 'feed',
name: 'Facebook Dialogs',
link: 'https://developers.facebook.com/docs/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
最佳答案
FB.ui
方法的function参数是回调。当FB.ui
完成其应做的工作时调用(在此处张贴墙贴)
要摆脱确认,您只需要摆脱回调或让其为空即可。但是,通常非常重要的是要知道FB.ui
是否已成功完成了应做的事情,例如检查用户是否尚未取消该动作。这就是为什么存在回调的原因。您可以将它们转换为所需的任何东西。无论如何,该对话框都会关闭。
FB.ui({
method: 'feed',
name: 'Facebook Dialogs',
link: 'https://developers.facebook.com/docs/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple applications to users interface.'
},
function(response) {
if (response && response.post_id)
// Do whatever you need if the post is successfull
else
// Do whatever you need if the post failed
});
希望能有所帮助!
关于javascript - 避免在FB.ui上进行确认,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22182060/