wordpress開啟允許評論多層嵌套之後,在回覆評論時出現「addcomment 未定義js代碼錯誤」提示。查看源代碼,發現在「回覆」鏈接中的確是加了:onclick='return addComment.moveForm。解決Wordpress addcomment 未定義js代碼錯誤問題就要添加一個js,具體代碼如下:


addComment = {
  moveForm : function(commId, parentId, respondId, postId) {
var t = this, div, comm = t.I(commId), respond = t.I(respondId), cancel = t.I('cancel-comment-reply-link'), parent = t.I('comment_parent'), post = t.I('comment_post_ID');

if ( ! comm || ! respond || ! cancel || ! parent )
return;

t.respondId = respondId;
postId = postId || false;

if ( ! t.I('wp-temp-form-div') ) {
div = document.createElement('div');
div.id = 'wp-temp-form-div';
div.style.display = 'none';
respond.parentNode.insertBefore(div, respond);
}

comm.parentNode.insertBefore(respond, comm.nextSibling);
if ( post && postId )
post.value = postId;
parent.value = parentId;
cancel.style.display = '';

cancel.onclick = function() {
var t = addComment, temp = t.I('wp-temp-form-div'), respond = t.I(t.respondId);

if ( ! temp || ! respond )
return;

t.I('comment_parent').value = '0';
temp.parentNode.insertBefore(respond, temp);
temp.parentNode.removeChild(temp);
this.style.display = 'none';
this.onclick = null;
return false;
}

try { t.I('comment').focus(); }
catch(e) {}

return false;
},

I : function(e) {
return document.getElementById(e);
}
}

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 wiboyn33423 的頭像
    wiboyn33423

    E資訊廣場

    wiboyn33423 發表在 痞客邦 留言(0) 人氣()