简体   繁体   中英

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:

$.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.

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). 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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