简体   繁体   English

如何从链接调用Facebook JavaScript?

[英]how to call facebook javascript from a link?

i have this code: 我有此代码:

<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>

how do i call this function from this link: <a href="#">test</a> 我如何从以下链接调用此函数: <a href="#">test</a>

any ideas? 有任何想法吗?

thanks 谢谢

edit: more about the facebook code here 编辑:更多关于facebook代码在这里

I don't really understand the question. 我不太明白这个问题。 From the way I interpret it, it seems to me that all you need to do is have an onclick event for that hyperlink which runs the script you have provided. 从我理解的方式,在我看来,所有你需要做的是有它运行您所提供的脚本,超链接的onclick事件。

you can use it this way: 您可以通过以下方式使用它:

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

in your jquery code: 在你的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',
          });
})
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM