将一个click()事件附加到FaceBook'Like'按钮? [英] Attach a click() event to the FaceBook 'Like' button?
问题描述
当用户点击喜欢时,我想在页面上执行某些操作。
I'd like to do something on the page when a user clicks 'Like'.
我以为一些简单的例子,如下所示:
I thought something simple like the following would work:
<script type="text/javascript">
$(document).ready(function () {
$('.connect_widget_like_button clearfix like_button_no_like').live('click', function () {
alert('clicked');
});
});
</script>
这是FaceBook用于将Like按钮添加到页面的iFrame:
This is the iFrame that FaceBook supplies to add the Like button to the page:
<iframe
id="FBLike"
src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.MySite.Com... blahblahblah"
scrolling="no"
frameborder="0"
style="border:none; overflow:hidden; width:450px; height:80px;"
allowTransparency="true">
</iframe>
我的脚本尝试将点击事件绑定到页面加载到iFrame中的锚标签负载。它不工作虽然有没有什么办法让我得到jQuery来识别何时被点击?感谢
My script attempts to bind a click event to an anchor tag that is loaded into the iFrame when the page loads. It doesn't work though. Is there any way for me to get jQuery to recognise when this is clicked? Thanks
推荐答案
Facebook API不允许您订阅类似的点击事件,但它允许您订阅喜欢发生事件(类似动作完成时触发):
Facebook API doesn't allows you to subscribe to the like clicking event, but it allows you to subscribe to the like happening event (fired when the like action is completed):
FB.Event.subscribe('edge.create', function(response) {
// like clicked
});
请参阅 here 。
这篇关于将一个click()事件附加到FaceBook'Like'按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!