Facebook分享按钮不会显示在Chrome中

Wil*_*ill 3 javascript share facebook google-chrome

我正在建立一个rails应用程序,我无法让Facebook Share按钮在Chrome或Firefox中显示.它在IE和Safari中显示得很好.Like和Login按钮适用于所有浏览器.我在网上搜索过,但找不到任何有用的东西.

在我的每一页上

<!-- Facebook SDK -->
<div id="fb-root"></div>
<script>
window.onload = function()
{
  // Additional JS functions here
  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'XXXXXXXXXXXXXXX', // App ID
      channelUrl : '//localhost:3000/channel.html', // Channel File
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      xfbml      : true  // parse XFBML
    });

  (function(d){
   var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
   if (d.getElementById(id)) {return;}
   js = d.createElement('script'); js.id = id; js.async = true;
   js.src = "//connect.facebook.net/en_US/all.js";
   ref.parentNode.insertBefore(js, ref);
  }(document));

}
Run Code Online (Sandbox Code Playgroud)

在页面上我希望出现"共享"按钮,我有

<fb:share-button type="button_count"></fb:share-button>
Run Code Online (Sandbox Code Playgroud)

根据Adam的建议,我创建了一个HTML文件.出现登录按钮,但共享按钮不显示

<!DOCTYPE HTML>
<HTML xmlns:fb="http://ogp.me/ns/fb#">
<HEAD>
   <TITLE>Untitled HTML Document</TITLE>
</HEAD>

<BODY BGCOLOR="white">
<div id="fb-root"></div>

<script>

  (function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=MY_APP_ID"; // APP ID
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

</script>
FB
<fb:share-button type="box_count"></fb:share-button> <br>
<div class="fb-login-button" data-width="200"></div>
</BODY>
</HTML>
Run Code Online (Sandbox Code Playgroud)

Wil*_*ill 5

看起来问题是我使用localhost作为我的网址.我更改了我的/ etc/hosts文件,以便fakeurl.com指向127.0.0.1并且它现在正常工作.