作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我正在尝试使用 Disqus api,我需要运行一些修改 Disqus 评论线程的 javascript 代码。
如何在 Disqus 线程加载后运行 javascript 代码?
最佳答案
我遇到了类似的问题。我能想到的唯一可行的解决方案是运行 setInterval()
来检查 Disqus 容器 div 的高度。
例子:
var editable = true; // set a flag
setInterval(function() {
// Initially Disqus renders this div with the height of 0px prior to the comments being loaded. So run a check to see if the comments have been loaded yet.
var disqusHeight = $('#dsq-2').height();
if ( disqusHeight > 0 ) {
if (editable) { // To make sure that the changes you want to make only happen once check to see if the flag has been changed, if not run the changes and update the flag.
editable = false;
// Your code here...
}
}
}, 100);
关于javascript - 如何在加载 Disqus 后运行 javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17004009/
我是一名优秀的程序员,十分优秀!