【发布时间】:2015-10-11 08:54:04
【问题描述】:
总结: 我正在设置 disqus 以在我们的 MVC .net 站点内的页面上显示评论计数。我之前在 Tumblr 页面上“修复”过这个功能,所以我认为我有必要的技能在这个网站上相当容易地做到这一点,但我失败了。我还查看了 Ryan (https://stackoverflow.com/users/1370956/ryan-v) 的所有适用答案,但没有找到解决方案。
我正在遵循 disqus.com 的指示:
https://help.disqus.com/customer/portal/articles/565624
但我没有成功。我的理解是,我需要做的就是:
- 添加替换了 disqus_shortname 的脚本
- 在文章网址末尾插入带有“#disqus_thread”的href标签
一旦完成,我认为脚本应该插入评论计数并将其显示在页面上——但这对我不起作用。
在 tumblr 你应该插入一个元标记
<meta name='text:Disqus Shortname' content='' />
但我不认为这适用于我的设置(尽管这并没有阻止我尝试一下)。
我只能假设我遗漏了一些明显的东西。我想知道 localhost 环境是否会中断我的测试,因为我正在使用指向显示 disqus cmets 的 localhost 页面的链接。我还使用实时 disqus 评论页面进行了测试,但结果相同。
详情: 目前我已经测试了一些错误的东西,但我认为以下是错误最少的:
脚本:
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'My-Shortname'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function () {
var s = document.createElement('script'); s.async = true;
s.type = 'text/javascript';
s.src = '//' + disqus_shortname + '.disqus.com/count.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
</script>
<a href="http://localhost-link/#disqus_thread"></a>
【问题讨论】:
标签: javascript html comments disqus