我喜欢的按钮代码如下:
<div class="like-btn">
<fb:like href="http://www.example-url.com" layout="box_count" show_faces="true" width="450" action="like" colorscheme="light" ></fb:like>
</div>
我的问题是,我不想在点击之后显示评论框。我正在使用Like Button的XFBML版本进行跟踪,所以评论框是不可避免的
我在页面中有多个类似按钮的变量href
我已阅读有关删除此方案中的评论框的所有问题/解决方案,但它们都不起作用。我希望刷新<div class="like-btn">
的内容会有所帮助。
有人可以帮我弄清楚我应该如何解决这个问题吗?
到目前为止,这是我的尝试:
//copying content of the div since the href is retrieved via php and is variable
var content = $('.like-btn').html();
$('.like-btn').empty();
$('.like-btn').html(content);
接受的答案中显示的方法适用于默认类似按钮(XFBML / HTML5),但不适用于box-count
样式。
答案 0 :(得分:2)
您可以通过代码分析获取评论框类,并应用Solomon Closson的CSS答案将其从页面显示中删除。
类似的东西:
<style type="text/css">
.like-btn-comment-box { display: none !important; }
</style>
其中.like-btn-comment-box
是评论框类
答案 1 :(得分:1)
根据您当前使用它的方式,尝试将其添加到页面中:
<style type="text/css">
.like-btn {
height: 25px;
overflow: hidden;
}
</style>
如果这不起作用,请使用HTML5代码显示FB Like按钮,如下所示:
<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";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<style type="text/css">
.fb-like{
height: 25px;
overflow: hidden;
}
</style>
<div class="fb-like" data-href="http://developers.facebook.com/docs/reference/plugins/like" data-width="450" data-show-faces="false" data-send="true"></div>
我们将.fb-like
的高度设置为25 pixels
和overflow: hidden
,这会阻止评论框完全弹出!
您可以在此处看到它:http://devs.dream-portal.net/dp11/index.php
对于盒子计数样式,您可以使用iframe版本作为盒子计数,并且不会显示任何评论框(至少不显示):
<iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Freference%2Fplugins%2Flike&width=450&height=65&colorscheme=light&layout=box_count&action=like&show_faces=true&send=true" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:65px;" allowTransparency="true"></iframe>
您还可以使用114张投票查看此stackoverflow问题的热门答案:Facebook Like Button - how to disable Comment pop up?
尝试一下,也许它会起作用......不确定。