脸书开放图
问题,
我可以将打开的图形 url 留空,但动态地将 url 传递给按钮并使其正常运行吗?
该 URL 是动态的,并通过 ajax 根据页面上的用户交互进行更新。因此,如果我在 og 元中放置一个值,它将与实际页面 url(用户交互后)不同。
谢谢。
或者使用 FBML - 动态更新 fb:like 按钮是否存在任何问题,例如:
<script>
var fb_ps_page = window.location.href;
document.write('<fb:like href=" '+ fb_ps_page +'" send="false" layout="button_count" width="450" show_faces="false"></fb:like>');
</script>
Question,
Can I leave the open graph url blank, but dynamically pass the url to the button and have it function properly?
The url is dyanamic and updated by ajax from user interactions on the page. So if I put a value in the og meta, it will be different than the actual page url (after user interactions).
thanks.
or by using FBML - is there any issue updating the fb:like button dynamically like:
<script>
var fb_ps_page = window.location.href;
document.write('<fb:like href=" '+ fb_ps_page +'" send="false" layout="button_count" width="450" show_faces="false"></fb:like>');
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,您无法动态更新“点赞”按钮的链接。您必须将其从 DOM 中删除并重新插入。然后调用 FB.XFBML.parse() 让 facebook 使用新的 url 渲染其 iframe。
No, you cannot dynamically update the link for the like button. You will have to remove it from the DOM and reinsert it. Then call FB.XFBML.parse() to get facebook to render their iframe with the new url.