如何从链接中调用facebook javascript?

时间:2012-01-05 21:34:39

标签: javascript facebook hyperlink

我有这段代码:

<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代码here

的更多信息

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:-1)

你可以这样使用它:

<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',
          });
})
})