小编Mat*_*mer的帖子

FB.Event.subscribe没有为某些事件触发

所以当用户点击"喜欢"按钮时,我正在尝试进行一些事件处理.

我的Facebook按钮是通过以下方式异步创建的:

(function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
    '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
}());
Run Code Online (Sandbox Code Playgroud)

这很有效.

我也运行以下功能:

window.fbAsyncInit = function() {
    FB.init({status: true, cookie: true, xfbml: true});
    FB.Event.subscribe("xfbml.render", function() {
        console.log('xfbml.render');
        FB.Event.subscribe("edge.create", function(targetUrl) {
            console.log('edge.create');
        });
        FB.Event.subscribe("edge.remove", function(targetUrl) {
            console.log('edge.remove');
        });
    });
};
Run Code Online (Sandbox Code Playgroud)

到目前为止,当我加载页面时,我在控制台中得到'xfbml.render'.然后我点击"赞"按钮,我什么都没得到.

我想把它吐出控制台消息'edge.create'.

有谁知道是什么原因引起的?

我之前将这个页面放在一个可公开访问的网站上(它目前在我的开发平台上)并且它仍然无效.如果要求,我可以再次.

facebook xfbml facebook-like facebook-javascript-sdk

4
推荐指数
1
解决办法
1万
查看次数