简体   繁体   English

刷新包含facebook的div按钮

[英]refresh div containing facebook like button

My like button code goes as follows: 我喜欢的按钮代码如下:

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

My problem is that, I do not want the comment box to be displayed after clicking like. 我的问题是,我不想在点击之后显示评论框。 I'm using XFBML version of Like Button for tracking purpose, so comment box is inevitable. 我正在使用Like Button的XFBML版本进行跟踪,所以评论框是不可避免的。
I have multiple like buttons in the page with variable href's. 我在页面中有多个类似按钮的变量href。
I have read all the questions/solutions regarding removing the comment box in this scenario, but none of them work. 我已阅读有关删除此方案中的评论框的所有问题/解决方案,但它们都不起作用。 I'm hoping that Refreshing the contents of <div class="like-btn"> would help. 我希望刷新<div class="like-btn">会有所帮助。

Could someone please help me figure out how I should tackle this problem? 有人可以帮我弄清楚我应该如何解决这个问题?

Here is my attempt so far: 这是我到目前为止的尝试:

//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);

UPDATE UPDATE

The approach shown in the accepted answer works perfectly for the default like button (XFBML/HTML5) but not for the box-count styled. 接受的答案中显示的方法适用于默认类似按钮(XFBML / HTML5),但不适用于box-count样式。

You can get the comment box class via code analysis and apply Solomon Closson's CSS answer to remove it from page display. 您可以通过代码分析获取评论框类,并应用Solomon Closson的CSS答案将其从页面显示中删除。

Something like: 就像是:

<style type="text/css">
    .like-btn-comment-box { display: none !important; }
</style>

Where .like-btn-comment-box is the comment box class 其中.like-btn-comment-box是注释框类

With the way you are currently using it, try adding this to the page: 根据您当前使用它的方式,尝试将其添加到页面:

<style type="text/css">
.like-btn {
    height: 25px;
    overflow: hidden;
}
</style>

If that doesn't work, use the HTML5 Code for displaying the FB Like Button instead, something like this: 如果这不起作用,请使用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>

We set the height of .fb-like to 25 pixels and overflow: hidden , which will prevent the comment box from popping up completely! 我们将.fb-like的高度设置为25 pixelsoverflow: hidden ,这将阻止评论框完全弹出!

You can see it working here: http://devs.dream-portal.net/dp11/index.php 你可以在这里看到它: http//devs.dream-portal.net/dp11/index.php

UPDATED 更新

For the box-count style, you can use the iframe version for the box-count and no comment box gets displayed (atleast not to me): 对于盒子计数样式,您可以使用iframe版本作为盒子计数,并且不显示任何评论框(至少不显示给我):

<iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Freference%2Fplugins%2Flike&amp;width=450&amp;height=65&amp;colorscheme=light&amp;layout=box_count&amp;action=like&amp;show_faces=true&amp;send=true" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:65px;" allowTransparency="true"></iframe>

RE-UPDATED 再 - 更新

You can also review the Top Answer on this stackoverflow question here with 114 up votes: Facebook Like Button - how to disable Comment pop up? 你还可以在这里查看关于此stackoverflow问题的热门答案,获得114票: Facebook Like Button - 如何禁用评论弹出窗口?

Try that and maybe it will work... not sure. 尝试一下,也许它会起作用......不确定。

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

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