简体   繁体   English

如何为我的网站实现Facebook“赞”按钮

[英]How to implement the Facebook “Like” button for my website

I am trying to implement facebook like button on my website. 我正在尝试在我的网站上实现facebook like button。 The first four lines in the code is already there on my site after the end of the "" tag. 在“”标记结束后,代码中的前四行已存在于我的网站上。

To implement the "Like button" i have added the second script (Line five to the end) and ran the application. 为了实现“Like按钮”,我添加了第二个脚本(第五行到结尾)并运行了应用程序。 Its giving me an error as 它给我一个错误

" Microsoft Jscript runtime error:'_onLoad' is null or not an object " Microsoft Jscript运行时错误:'_ onLoad'为null或不是对象

Please Let me know. 请告诉我。 Thanks 谢谢

<script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php"></script>
<script type="text/javascript">
    FB.init("myapikey", "xd_receiver.htm", { "reloadIfSessionStateChanged": true });
</script>
<script type="text/javascript">
  window.fbAsyncInit = function() {
    FB.init({appId: 'myappid', status: true, cookie: true,
             xfbml: true});
  };
  (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
      '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
  }());
</script>

References: http://developers.facebook.com/docs/reference/plugins/like 参考文献: http//developers.facebook.com/docs/reference/plugins/like

<fb:like href="http://webclip.in" layout="standard" show-faces="true" width="450" action="like" font="arial" colorscheme="light"/>

There is a new way to add the like button on your site. 一种新方法可以在您的网站上添加“赞”按钮。

go to this page, http://developers.facebook.com/docs/reference/plugins/like-box 转到此页面, http://developers.facebook.com/docs/reference/plugins/like-box

and create the code by plasing your parametres and click the "Get Code" 并通过填充参数来创建代码,然后单击“获取代码”

This is an example 这是一个例子

<iframe 
    src="http://www.facebook.com/plugins/likebox.php?id=185550966885&amp;width=292&amp;connections=10&amp;stream=true&amp;header=true&amp;height=587" 
    scrolling="no" frameborder="0" 
    style="border:none; overflow:hidden; width:292px; height:587px;" allowTransparency="true">
    </iframe>

or just (if you using Javascript SDK of facebook) 或者只是(如果你使用facebook的Javascript SDK)

<fb:like-box profile_id="185550966885"></fb:like-box>

Also in the page http://developers.facebook.com/docs/reference/plugins/like there is a Get Code... thats works, no need to add this javascript on your code. 另外在页面http://developers.facebook.com/docs/reference/plugins/like中有一个获取代码...这样可行,无需在您的代码上添加此javascript。

With the new API, you may need to also add the following div after your body tag and before you load any facebook javascript 使用新的API,您可能还需要在body标签之后和加载任何facebook javascript之前添加以下div

<div id="fb-root"></div> <div id =“fb-root”> </ div>

Otherwise you may get a 'root' object is null error 否则你可能会得到一个'root'对象是null错误

Per documentation here http://developers.facebook.com/docs/reference/javascript/ 每个文档http://developers.facebook.com/docs/reference/javascript/

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

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