简体   繁体   English

FB.UI被浏览器阻止了吗?

[英]FB.UI was blocked by browser?

I'm integrating FB sdk to my website, I'm use FB.UI to init share dialog, but it was blocked by browser, there is anyway to display popup share dialog, here is my code: 我正在将FB sdk集成到我的网站中,我使用FB.UI来初始化共享对话框,但是它被浏览器阻止,总之有显示弹出共享对话框的代码,这是我的代码:

$.ajax({
    type: "POST",
    url: urlApi,
    data: json
}).done(function (data) {
    var obj = jQuery.parseJSON(data);
    var resp = jQuery.parseJSON(data);
    if (resp.success == "1") {
        var option = { method: 'feed', link: resp.link, title: resp.title, caption: resp.url, name:resp.title, display: "popup" };
         FB.ui(option);
  } 
});

Note: I can not user DIRECT URL share dialog, because I need data response from FB so I use javascript api. 注意:我无法使用DIRECT URL共享对话框,因为我需要FB的数据响应,因此我使用javascript API。

Browsers will block popup windows if they are not spawned by the result of a direct user click. 如果浏览器未因用户直接单击而产生,则会阻止弹出窗口。 In your example, FB.ui is being called on success of an ajax call (not a direct user class click). 在您的示例中,成功执行ajax调用(不是直接单击用户类)时将调用FB.ui。 Without providing more of your code, or context, all I can suggest is that you will need to rethink your architecture in order to achieve your ajax call and then FB share dialog. 在不提供更多代码或上下文的情况下,我只能建议您需要重新考虑体系结构,以实现Ajax调用和FB共享对话框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM