Facebook 喜欢 JavaScript 添加时不工作
所以我想为我的个人帖子添加一个“赞”。所以我将其添加到每个帖子中。这些帖子是从数据库输出生成的,然后在 JavaScript 文件中使用正确的样式进行组装。
所以我将其添加到创作组合中。
<fb:like href="my_not_so_sweet_website" layout="button_count" show_faces="true" width="200"></fb:like>
奇怪的是...他们都没有出现。然后我尝试获取为每个帖子生成的代码,然后将其复制并粘贴到我的网站顶部,然后低头看到一个类似按钮!!!。有什么线索吗?需要更多信息吗?帮助?
So i am trying to add a like to my individual posts. So i added this to each of the posts. The posts are generated from database output then assembled with the properly styling in a javascript file.
So i added this to the creation mix.
<fb:like href="my_not_so_sweet_website" layout="button_count" show_faces="true" width="200"></fb:like>
Weird part is... None of them show up. THEN i try taking that code that i generated for each post and just copy and paste it to the top of my website, and low and behold A like Button!!!. Any clues? Need more info? Help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在使用所谓的 FBML。 Like 按钮是由您在页面上包含的 facebook javascript 库动态渲染的(好吧,在页面加载时)——它需要 FBML 标签来知道要渲染什么。
问题在于 FB 库不够智能,无法知道您已将这些 FBML 标签动态添加到 DOM 中。
还有另一种类型的类似按钮,它是 iframe,如果您动态地将其放入 DOM 中,该按钮应该可以工作。相关文档在这里: http://developers.facebook.com/docs/reference/ plugins/like/
- 当您在小部件中输入信息时,将会有一个 iframe 选项。
FB javascript SDK 中还有一个 FBML 渲染函数。文档在这里: http://developers.facebook.com/docs/参考/javascript/fb.xfbml.parse/
You are using what's called FBML. The like button is rendered on the fly (well, on page load) by a facebook javascript libabry you include on the page- it needs the FBML tags to know what to render.
The problem is that the FB library isn't smart enough to know that you've dynamically added these FBML tags to the DOM.
There is another type of like button that's an iframe, that one should work if you put it in the DOM dynamically. Docs for that are here: http://developers.facebook.com/docs/reference/plugins/like/
-when you enter your info into the widget there will be an option for iframe.
There is also a FBML render function in the FB javascript SDK. Docs are here: http://developers.facebook.com/docs/reference/javascript/fb.xfbml.parse/