如何检查社交分享按钮上的点击事件,即Googleplus,Facebook,Twitter,Digg,StumbleUpon,LinkedIn,Delicious,Reddit,Pinterest?

时间:2012-03-15 05:53:30

标签: javascript button javascript-events share social

对于Googleplus,我们可以使用callback标记内的g:plusone属性。

<g:plusone size="small" callback="check_googleplus_click"></g:plusone>

function check_googleplus_click(jsonParam)
{
    alert("googleplus was clicked")
    console.debug(jsonParam);
}

如何查看Facebook,Twitter,Digg,StumbleUpon,LinkedIn,Delicious,Reddit,Pinterest?任何部分贡献都将非常有用。

2 个答案:

答案 0 :(得分:1)

对于Facebook,您可以使用FB.Event.subscribe来确定何时单击Like按钮。

window.fbAsyncInit = function () {
    FB.init({ appId: 'YOUR_APP_ID', status: true, cookie: true,
        xfbml: true
    });
    FB.Event.subscribe('edge.create', function (response) {
       //Do something when an user click on Like Button (to "Like" something).
       console.log(response);
    }
    FB.Event.subscribe('edge.remove', function (response) {
       //Do something when an user click on Like Button (to "unlike" something).
       console.log(response);
    }
}

答案 1 :(得分:1)

    Here is for twitter..
    <script>
      window.twttr = (function (d,s,id) {
     var t, js, fjs = d.getElementsByTagName(s)[0];
     if (d.getElementById(id)) return; js=d.createElement(s); js.id=id;
     js.src="//platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs);
     return window.twttr || (t = { _e: [], ready: function(f){ t._e.push(f) } });
     }(document, "script", "twitter-wjs"));
    function clickEventonTweeter(intent_event) {
    if (intent_event) {
  //write your code here
   };
 }
    twttr.ready(function (twttr) {
   twttr.events.bind('click', clickEventonTweeter);
   });  

我现在正试图寻找pinterest ..