为了将 facebook 插件评论框的脚本编辑为动态并分别显示与每个帖子相关的评论,我在脚本中添加了这两行代码:
var related = document.getElementById('fb-related');
related.setAttribute("data-href", "articles.aspx?art_id=<%# Request.QueryString["art_id"] %>"); ... (the rest of code) </script>
这是评论框出现的 div
<div id="fb-related" class="fb-comments" data-numposts="5" data-colorscheme="light"></div>
但是没有任何反应,评论框根本不出现,或者出现评论插件需要一个 href 参数。!有什么帮助吗?
请注意 我将 asp.net 与 C# 一起使用
最佳答案
使用 C# 代码将 CodeBehind 中的 data-href 属性放在 PageLoad 事件上,这样当页面呈现时,插件就已经有了 data-href
关于c# - 编辑评论框脚本为动态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20837096/