我可以创建吗?在javascript中以编程方式按钮?
我正在开发 Facebook 应用程序(iframe),一旦我知道要喜欢的 href 是什么(例如:要喜欢的项目会根据页面上的选择进行更改等),需要在运行时在 Javascript 中添加一个框。
创建一个像这样的框:
<fb:like href="http://example.com" send="true" action="recommend" width="360" layout="standard" show_faces="true" />
或其 HTML5 等效项:
<div class="fb-like" data-href="http://example.com" data-send="true" data-width="360" data-show-faces="true" data-action="recommend"></div>
有没有办法在运行时用 Javascript/jQuery
?我已经尝试使用 iframe 之类的框,但它不支持“发送”,所以这将是我的后备选择。该标签对我来说效果很好,但我不知道如何在运行时更改其 href。
PS:我确实包含了 Javascript SDK,有一个登录会话等。
如有任何帮助,我们将不胜感激, 吉奥纳塔·梅蒂福戈
I am working on a Facebook App (iframe) and need to add an box at runtime in Javascript once I know what is the href to like (eg: the item to like changes based on selection on the page, etc).
Is there a way to create a box like this:
<fb:like href="http://example.com" send="true" action="recommend" width="360" layout="standard" show_faces="true" />
or its HTML5 equivalent:
<div class="fb-like" data-href="http://example.com" data-send="true" data-width="360" data-show-faces="true" data-action="recommend"></div>
in Javascript/jQuery at runtime?
I already tried using the iframe like box but it doesn't support "send" so it would be my fallback choice. The tag works well for me but I can't figure out how to change its href at runtime.
PS: I do include the Javascript SDK, have a logged in session, etc.
Any help is appreciated,
Gionata Mettifogo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 facebook 的 Javascript API 的
setInnerFBML
在页面上动态设置 FBML 对象。请注意,您必须将 FBML 字符串预渲染到对象中。
您可以在这里阅读更多相关信息:
https://developers.facebook.com/docs/fbjs/#fbml
在这里:http://forum.developers.facebook.net/viewtopic.php? id=20157
You can use facebook's Javascript API's
setInnerFBML
to set FBML objects dynamically on page.Note that you have to pre-render the FBML string into an object.
You can read more about it here:
https://developers.facebook.com/docs/fbjs/#fbml
and here: http://forum.developers.facebook.net/viewtopic.php?id=20157