修改多说评论代码使其支持ajax
想弄ajax很久了 这次直接弄成全站ajax
但是多说有很大问题 无法在加载后显示出来
去看官方教程 竟然入坑 了 其实并不用那么复杂
现在将代码贴上了 适当改里面代码即可
<span id="expandComments" onclick="toggleDuoshuoComments('#comment-box');">展开评论</span>
<div id="comment-box" ></div>
<script type="text/javascript">
var duoshuoQuery = {short_name:"xhily"};
function toggleDuoshuoComments(container){
$("#expandComments").hide();
var el = document.createElement('div');//该div不需要设置class="ds-thread"
el.setAttribute('data-thread-key', '<?php echo $this->cid;?>');//必选参数
el.setAttribute('data-url', '<?php echo $this->title;?>');//必选参数
DUOSHUO.EmbedThread(el);
jQuery(container).append(el);
}
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true;
ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//www.xhily.cn/embed.js';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
将红色地方改成自己的就ok啦 直接替换 comments.php
只适用于Typecho 这样 评论就可以在加载后 通过点击 展开评论 显示评论
版权声明:本博客所有文章除特别声明外,均采用 CC BY 4.0 CN协议 许可协议。转载请注明出处!



www.xevip.cn
您好
无用笔记@您好
您好@无用笔记
无用笔记@您好
无用笔记@您好
您好
无用笔记@您好
您好@无用笔记
无用笔记@您好
您好@无用笔记