【问题标题】:Iframe Like button not firing edge.createiframe Like 按钮未触发 edge.create
【发布时间】:2012-10-16 08:48:21
【问题描述】:

我不想使用 xfbml。我需要使用像下面这样的 iframe 按钮。但这不会触发edge.create

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
// initalize your Facebook App
  FB.init({
    appId  : '113869198637480',
    status : true, // check login status
    cookie : true, // enable cookies to allow the server to access the session
    xfbml  : true  // parse XFBML
  });
// subscribe to the event
FB.Event.subscribe('edge.create', function(response) {
  alert('you liked this');
});
FB.Event.subscribe('edge.remove', function(response) {
  alert('you unliked this');
});
</script>

<iframe id="test" src="http://www.facebook.com/plugins/like.php? 
       href=http://google.com/&amp;
       layout=button_count&amp;
       show_faces=false&amp;
       width=50&amp;
       action=like&amp;
       colorscheme=light&amp;
       height=21" 
       scrolling="no" frameborder="0" 
       style="border:none; overflow:hidden; width:50px;  
              height:21px;" 
       allowTransparency="true">

【问题讨论】:

  • 不,使用 iframe 版本不可能
  • 是的,不要使用 iframe 版本;)
  • 您必须使用 xfbml。期间。

标签: facebook iframe facebook-like


【解决方案1】:

这完全是意料之中的; javascript 回调仅在使用 Javascript 版本的社交插件时可用,包括点赞按钮。

Like Button documentation中提到了这个:

How do I know when a user clicks a Like button?

If you are using the XFBML version of the button, you can subscribe to the 'edge.create' event through FB.Event.subscribe.

当您将 Like 按钮直接包含为 iFrame 时,来自 Facebook 服务器的事件无法传播回您的 javascript 代码 - Facebook Javascript SDK 在使用 XFBML 版本的 Like 按钮时处理此通信

【讨论】:

  • 谢谢,我知道,我仍然需要一种方法(甚至丑陋和 hacky)来检测 iFrame 之类的按钮
  • 不幸的是这是不可能的
  • 如果你能得到点赞按钮的准确坐标 (x,y),你可能会得到客户端鼠标点击坐标并假设它是点赞点击。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多