Khắc phục lỗi reply (trả lời) trên blogspot mới nhất

Bài viết Khắc phục lỗi reply (trả lời) trên blogspot mới nhất 2019 tại Bloghong.com tham khảo thêm hoặc cần tư vấn Khắc phục lỗi reply (trả lời) trên

 Gần đây một số blog bị lỗi không trả lời (reply) comment được trên blog của mình, hóng mãi mới có cao nhân sữa được lỗi này. Cách này vừa sữa lỗi vừa tối ưu bớt js, được hướng dẫn bởi Blog Hồng. Các bạn cùng xem hướng dẫn nhé.

Khắc phục lỗi reply (trả lời) trên blogspot mới nhất

Đầu tiên: Tích hợp jQuery (nếu blog chưa có): dán sau thẻ <head>

<script src='//cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js' type='text/javascript'></script>

1. Sữa lỗi reply comment đối với Blog1 version 1

Tìm đến thẻ <b:includable id='threaded_comment_js' var='post'> và thay toàn bộ nội dung bên trong nó thành:

<script type='text/javascript'>//<![CDATA[

$(function() {

const t = $("#comment-editor-src").attr("href");

$(".comment-reply").each(function() {

var e = $(this);

e.on("click", function(n) {

$(".comment-actions").show(), n.preventDefault();

let r = e.parents("li").attr("id").substr(1),

c = t.split("?");

$("#comment-editor")[0].src = c[0] + "?parentID=" + r + "&" + c[1], e.parent().hide(), e.parents("li").append($(".comment-form")[0])

})

})

});

//]]></script>

2. Sữa lỗi reply comment đối với Blog1 version 2

Tìm đến thẻ <b:includable id='threadedCommentJs' var='post'> và thay toàn bộ nội dung bên trong nó thành:

<script>//<![CDATA[

$(function() {

const t = $("#comment-editor-src").attr("href");

$("a[o='r']").each(function() {

var n = $(this);

n.on("click", function(e) {

$(".comment-actions").show(), e.preventDefault();

let o = n.parents(".comment-block").attr("id").substr(1),

c = t.split("?");

$("#comment-editor")[0].src = c[0] + "?parentID=" + o + "&" + c[1], n.parent().hide(), n.parents("li").append($(".comment-form")[0])

})

})

});

//]]></script>

Chỉ mấy bước đơn giản vậy thôi, blog mình version 1 cũng bị lỗi và đã fix được ở bước 1.

Cập nhật: áp dụng chung cho Ver1 và Ver2

<script type='text/javascript'>//<![CDATA[

$(window).on("load", function() {

function n(n, t) {

$(n).each(function() {

var n = $(this);

n.on("click", function(e) {

$(".comment-actions,.cancel-comment").show(), e.preventDefault();

let c = n.parents(t).attr("id").substr(1),

m = o.split("?");

$("#comment-editor")[0].src = m[0] + "?parentID=" + c + "&" + m[1], n.parent().hide(), n.parents("li").append($(".comment-form")[0])

})

})

}

$(".comment-form").append('<a class="cancel-comment" style="font-family:Roboto,sans-serif;font-weight:700;font-size:12px;color:#ff0000;cursor:pointer;">CANCEL</a>'), $(".cancel-comment").hide();

const o = $("#comment-editor-src").attr("href");

$(".comment-block[id]").length ? n("a[o='r']", ".comment-block") : n(".comment-reply", "li"), $(".cancel-comment").on("click", function() {

$(".comment-actions").show(), $("#comment-editor")[0].src = o, $(".comments-content").before($(".comment-form")[0]), $(this).hide()

})

});

//]]></script>

Đăng nhận xét

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
Site is Blocked
Sorry! This site is not available in your country.