Disqus: change captions after success with jQuery

徘徊边缘 提交于 2019-12-06 11:04:38

问题


Disqus automatically places defined captions upon request. For example: Add new Comment

I've tried to change its value with jquery on ready():

$('#dsq-new-post h3').text('Paticipa con tu cuenta favorita');

No success :( ... how can i know when disqus script is finished parsing the data so i can change the caption value of h3?

BTW, this is Disqus' call:

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

回答1:


Here is the answer andufo. It works:

$(document).ready(function() {
  window.disqus_no_style = true;

  $.getScript('http://sitename.disqus.com/embed.js', function() {
    var loader = setInterval(function() {
      if($('#disqus_thread').html().length) {
        clearInterval(loader);
        disqusReady();
      }
    }, 1000);
  });

  function disqusReady() {
    //whatever you can imagine
  }
});

You can comment out the $.getscript line and ending }); as well as the window.disqus_no_style = true; line.

I had a similar problem and posted this question. Mohamed attempted to answer me and his answer did not work but he'd posted a link to his code at github and I found the right answer there.

Chrome Extension iframe dom reference disqus

https://gist.github.com/471999




回答2:


This simple solution also works, although the original text appears first, then is replaced with the new text, which is less then ideal.

function disqus_callback() {
  $('#dsq-reply h3').text('Add Your Answer');
}


来源:https://stackoverflow.com/questions/2885972/disqus-change-captions-after-success-with-jquery

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!