admin管理员组文章数量:1325135
I'm buidling a rails app and I'm having trouble getting the Facebook Share button to display in Chrome or Firefox. It shows up fine in IE and Safari. The Like and Login buttons work fine in all browsers. I've searched the web, but can't find anything helpful.
On each page I have
<!-- 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/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
}
On the page I want the Share button to appear, I have
<fb:share-button type="button_count"></fb:share-button>
Per Adam's suggestion I created an HTML file. THe login button appears but the share button doesn't
<!DOCTYPE HTML>
<HTML xmlns: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/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>
I'm buidling a rails app and I'm having trouble getting the Facebook Share button to display in Chrome or Firefox. It shows up fine in IE and Safari. The Like and Login buttons work fine in all browsers. I've searched the web, but can't find anything helpful.
On each page I have
<!-- 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/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
}
On the page I want the Share button to appear, I have
<fb:share-button type="button_count"></fb:share-button>
Per Adam's suggestion I created an HTML file. THe login button appears but the share button doesn't
<!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/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>
Share
Improve this question
edited Sep 18, 2013 at 2:10
Will
asked Sep 17, 2013 at 6:52
WillWill
1631 gold badge4 silver badges12 bronze badges
2 Answers
Reset to default 5Looks like the problem was with me using localhost as my url. I changed my /etc/hosts file so that fakeurl. points to 127.0.0.1 and it works fine now.
Add xmlns:fb="http://ogp.me/ns/fb#"
to your <HTML>
tag:
<html xmlns:fb="http://ogp.me/ns/fb#">
Change your <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/en_US/all.js#xfbml=1&appId=YOUR_APP_ID"; // APP ID
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
Live demo
本文标签: javascriptFacebook Share button won39t display in ChromeStack Overflow
版权声明:本文标题:javascript - Facebook Share button won't display in Chrome - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742177130a2427782.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论