本文介绍了Disqus:使用jQuery成功后更改标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Disqus会根据要求自动放置定义的字幕.例如:添加新评论

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

我尝试使用ready()上的jquery更改其值:

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

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

没有成功:( ... ...我怎么知道Disqus脚本何时完成数据解析,所以我可以更改h3的标题值?

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

顺便说一句,这是Disqus的电话:

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);
})();

推荐答案

答案是andufo.它的工作原理:

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
  }
});

您可以注释掉$ .getscript行并以}结尾;以及window.disqus_no_style = true;线.

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

我有一个类似的问题,并发布了这个问题.穆罕默德(Mohamed)试图回答我,但他的回答没有用,但是他在github上发布了指向他的代码的链接,我在那里找到了正确的答案.

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扩展程序iframe dom参考目录

https://gist.github.com/471999

这篇关于Disqus:使用jQuery成功后更改标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 17:32