Show alert on a button click

蹲街弑〆低调 提交于 2019-12-07 04:46:27

问题


I'm using the default Facebook embed code:

<div id="fb-root"></div> 
<script src="http://connect.facebook.net/en_US/all.js#appId=176702405718664&amp;xfbml=1"> </script>
<fb:like href="http://domain.com" send="true" width="700" show_faces="false" action="recommend" font=""></fb:like>

.. but I'd like to show an alert if the user clicks 'recommend' or 'send' buttons. Please see this fiddle:

http://jsfiddle.net/4wB9x/1/

Thanks!


回答1:


you will have to subscribe to the edge.create event, it gets triggered when user clicks the like button.

FB.Event.subscribe('edge.create',
function(response) {
    alert('You liked the URL: ' + response);
   }
);

// for send you will have to use this

 FB.Event.subscribe('message.send',
function(response) {
    alert('You sent the URL: ' + response);
   }
); 


来源:https://stackoverflow.com/questions/7383032/show-alert-on-a-button-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!