English 中文(简体)
jqueryscript to monitoring disqus comment addition?
原标题:jquery script to monitor disqus comment addition?

I would like to write a small script to monitor the disqus comments added on a page and fire some notification callbacks whenever new comments are added.

我最简单的办法是定期监测#dsq-comments div的内容,并在修改其html内容时触发警示。

虽然这项工作将继续下去,但我不知道那里是否有任何更清洁的方法?


<><>Edit>: 正如“Pekka i”所建议的那样,在我的上安装了新配电。 这是我的主要关切之一,即把我与site。 现在,我有一个可行的解决办法。

function disqus_config() {
  this.callbacks.onNewComment = [function() {
       $.get("/notifications/newcomment?...", function(data) {
       });
  }];
}
最佳回答

There seems to be an onNewComment callback. See How can I capture Disqus commenting activity in my own analytics tool?

This blog post does a good job at documenting it.

问题回答

可以通过下列方式通过背书获取评论活动:

function disqus_config() {
  this.callbacks.onNewComment = [function() { trackComment(); }];
}

您将接替handComment;,由您自己负责。

Here is an example that loads Disqus comments dynamically using JavaScript, where you can find the discus_config function that will be fired when a new comment is added.

var loadDisqus = function() {
  window.disqus_identifier =  your thread id ;
  window.disqus_shortname =  disqus_shortname ;
  window.disqus_url =  http://your_domain.com/path ;
  window.disqus_title = page title ;
  window.disqus_config = function() {
    this.callbacks.onNewComment = [function() { myFunction() }];
  };

  (function() {
    var dsq = document.createElement( script );
    dsq.type =  text/javascript ;
    dsq.async = true;
    dsq.src =  //  + disqus_shortname +  .disqus.com/embed.js ;
    (document.getElementsByTagName( head )[0] ||
      document.getElementsByTagName( body )[0]).appendChild(dsq);
  })();

};




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签