Javascript 自定义 facebook 喜欢链接?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4596068/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
custom facebook like link?
提问by Dirty Bird Design
Is it possible to add a custom facebook like icon? I would like it to be part of an <ul>
and I don't really want to load another library their SDK or all the <meta>
tags....
是否可以添加自定义 Facebook 之类的图标?我希望它成为一个的一部分,<ul>
我真的不想加载另一个库,他们的 SDK 或所有<meta>
标签......
Has anyone implemented a custom like button? I don't need the counter etc that their buttons provide, and to be honest, they are ugly. I have been searching around for the last 2 hours with no real luck.
有没有人实现过自定义按钮?我不需要他们按钮提供的计数器等,老实说,它们很丑。在过去的 2 个小时里,我一直在四处寻找,但没有真正的运气。
I found this:
我找到了这个:
<a name="fb_share"></a>
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share"
type="text/javascript">
</script>
But it implements one of their buttons.
但它实现了他们的按钮之一。
EDIT:
编辑:
I have read their API, while very easy to use I don't like the buttons generated from their <iframe>
or XFBML code. I am simply looking to find out if there is a way to make a custom link from something like this:
我读过他们的 API,虽然很容易使用,但我不喜欢从他们的<iframe>
或 XFBML 代码生成的按钮。我只是想找出是否有办法从这样的东西制作自定义链接:
<ul>
<li><a href="some code here">Facebook</a></li>
</ul>
Am I missing something in their API? it always generates a HUGE button with a counter and their graphics, which is exactly what I don't want.
我在他们的 API 中遗漏了什么吗?它总是生成一个带有计数器及其图形的巨大按钮,这正是我不想要的。
采纳答案by StuperUser
If you're not hand crafting it, there's the Facebook developer "Like" API documentation
如果您不是手工制作,可以使用Facebook 开发人员“Like”API 文档
If their API doesn't expose what the generated buttons do for you to copy, one way to find out what the like button is actually doing (if it's not a hyperlink, and since it might be posting by ajax, this could happen) is finding out how the event is handled in javascript. This may be problematic if the script has been optimised/minified.
如果他们的 API 没有公开生成的按钮为您复制的内容,那么找出类似按钮实际上在做什么的一种方法(如果它不是超链接,并且由于它可能是由 ajax 发布的,这可能会发生)是找出如何在 javascript 中处理事件。如果脚本已被优化/缩小,这可能会出现问题。
Another approach is to find out what HTTP requests it generates, using Fiddlerto listen to the request and inspect it to see its target and any form data.
另一种方法是找出它生成的 HTTP 请求,使用Fiddler侦听请求并检查它以查看其目标和任何表单数据。
If you're happy with the functionality of the like button, but not its style, restyle it with CSS, this may be the safer option, as any API change may break any mimicked script.
如果您对 like 按钮的功能感到满意,但对其样式不满意,请使用 CSS 重新设置样式,这可能是更安全的选择,因为任何 API 更改都可能破坏任何模仿脚本。
Otherwise, unless you're designing your own icons, you can download the free silk icons, use the thumb up icon as an image, and slightly edit it for any mouse-over/click events that require different icons, and you can handle the events with JavaScript, JQueryor JQuery-UI(depending on which libraries you've already got loaded).
否则,除非您正在设计自己的图标,否则您可以下载免费的丝绸图标,将拇指向上图标用作图像,并针对需要不同图标的任何鼠标悬停/单击事件对其进行稍微编辑,并且您可以处理使用 JavaScript、JQuery或JQuery-UI 的事件(取决于您已经加载了哪些库)。
That should deal with the UI behaviour, any calls back to the server could be made with AJAX (JQuery AJAX documentation).
这应该处理 UI 行为,可以使用 AJAX(JQuery AJAX 文档)对服务器进行任何回调。
回答by Kaspar L. Palgi
I found from another post here:
我从这里的另一篇文章中找到:
<a title="send to Facebook" href="http://www.facebook.com/sharer.php?s=100&p[title]=YOUR_TITLE&p[summary]=YOUR_SUMMARY&p[url]=YOUR_URL&p[images][0]=YOUR_IMAGE_TO_SHARE_OBJECT" target="_blank"><span><img width="14" height="14" src="'icons/fb.gif" alt="Facebook" /> Facebook></a>
I used this and works well:)
我用过这个并且效果很好:)
回答by Luke Shaheen
Customizing the Like button is against Facebook's policies.
自定义 Like 按钮违反了 Facebook 的政策。
"While you may scale the size to suit your needs, you may not modify the Like Button in any other way (such as by changing the design)."
“虽然您可以缩放大小以满足您的需要,但您不能以任何其他方式(例如通过更改设计)修改“赞”按钮。”
回答by sandraqu
I found Chaddo's article on Custom Facebook Like Button (BlackHat Button)very effective using CSS to customize the button. You can download the zip source code. It works well, and could use improvement in regards to height.
我发现 Chaddo 在Custom Facebook Like Button (BlackHat Button)上的文章使用 CSS 自定义按钮非常有效。您可以下载zip 源代码。它运作良好,并且可以在高度方面进行改进。