如何获取评论的超链接?

时间:2014-07-30 16:04:12

标签: disqus

我对网络编码一般都很陌生,因此解释对代码片段非常有帮助。

有没有办法在用户发布内容并将其存储到变量时获取用户的评论链接?通过评论链接,我的意思是当您将鼠标悬停在x分钟/小时/天之前发布的任何评论时,您可以获得该链接。

1 个答案:

答案 0 :(得分:1)

Disqus在嵌入中公开onNewComment回调,因此如果您为此变量分配一个函数,则每次用户发布评论时都会调用该函数。

这是它的样子:

function disqus_config() {
    this.callbacks.onNewComment = [function(comment) { 
      alert(comment.id);
    }];
}

该评论ID也可用于构建评论的链接。像这样的东西可以取代alert(comment.id);

var postLink = window.location.href + '#comment-' + comment.id;

然后使用postLink变量

执行您想要的操作

请参阅此处了解文档:https://help.disqus.com/customer/portal/articles/466258