English 中文(简体)
诸如点击纽顿的“方框”活动
原标题:Facebook likebox event on clicking button

I m trying to use SDK Facebook to detect the click on the button "like" of the likebox and call a function , but it not working . Here s my code :

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>

    <body>
    </body>

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      :  xxxx , // App ID
      channelURL :  xxxx/facebook/channel.html , // Channel File
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      oauth      : true, // enable OAuth 2.0
      xfbml      : true  // parse XFBML
    });

    // Additional initialization code here
  };

  // Load the SDK Asynchronously
  (function(d){
     var js, id =  facebook-jssdk ; if (d.getElementById(id)) {return;}
     js = d.createElement( script ); js.id = id; js.async = true;
     js.src = "//connect.facebook.net/en_US/all.js";
     d.getElementsByTagName( head )[0].appendChild(js);
   }(document));
</script>
<script type="text/javascript">
FB.Event.subscribe( edge.create ,
    function(response) {
        alert( You liked the URL:   + response);
    }
);
</script>

<fb:like-box href="http://www.facebook.com/MarwenClubiiste" width="292" show_faces="false" stream="false" header="false"></fb:like-box>

</html>

请帮助,我确实需要这样做。

最佳回答

Like box has a known bug, where the edge.create event doesn t work if the user is logged out of facebook and has to login to LIKE the page. However it works fine if the user is already logged in. Here is a mention of this bug :

https://github.com/facebook/joint-js/issues/82

The Like button does not have this bug, and fires the event in both cases. You may have to replace the LikeBox with a Like button + some custom HTML of your own.

Try using non-asyncloading of facebook JS as well. 更有助于:

问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签