如何从链接调用facebookjavascript

how to call facebook javascript from a link?

本文关键字:调用 facebookjavascript 链接      更新时间:2023-09-26

我有这个代码:

<html xmlns:fb="https://www.facebook.com/2008/fbml">
  <body>
    <script src="http://connect.facebook.net/en_US/all.js"></script>
    <div id="fb-root"></div>
    <script>
      // assume we are already logged in
      FB.init({appId: '123050457758183', xfbml: true, cookie: true});
      FB.ui({
          method: 'send',
          name: 'People Argue Just to Win',
          link: 'http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html',
          });
     </script>
  </body>
</html>

我如何从这个链接调用这个函数:<a href="#">test</a>

有什么想法吗?

感谢

编辑:更多关于facebook代码在这里

我真的不明白这个问题。从我对它的理解来看,在我看来,你所需要做的就是为运行你提供的脚本的超链接创建一个onclick事件。

您可以这样使用它:

<a href="#" id="go-to-fb"> click this </a>

在您的jquery代码中:

$(function(){
   $("#go-to-fb").click(function(){
       FB.ui({
          method: 'send',
          name: 'People Argue Just to Win',
          link: 'http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html',
          });
})
})