为评论添加@reply功能

一、在评论页comments.php添加如下JS代码:

  1. <script language=>
  2. to_reply(commentID,author) {
  3. nNd=\’@\’+author+\’:\’;
  4. myField;
  5. (document.getElementById(\’comment\’) && document.getElementById(\’comment\’).type == \’textarea\’) {
  6. myField = document.getElementById(\’comment\’);
  7. } {
  8. ;
  9. }
  10. (document.selection) {
  11. myField.focus();
  12. sel = document.selection.createRange();
  13. sel.text = nNd;
  14. myField.focus();
  15. }
  16. (myField.selectionStart || myField.selectionStart == \’0\’) {
  17. startPos = myField.selectionStart;
  18. endPos = myField.selectionEnd;
  19. cursorPos = endPos;
  20. myField.value = myField.value.substring(0, startPos)
  21. + nNd
  22. + myField.value.substring(endPos, myField.value.length);
  23. cursorPos += nNd.length;
  24. myField.focus();
  25. myField.selectionStart = cursorPos;
  26. myField.selectionEnd = cursorPos;
  27. }
  28. {
  29. myField.value += nNd;
  30. myField.focus();
  31. }
  32. }
  33. </script>

二、在functions.php中加入如下代码:

  1. to_reply() {
  2. ?>
  3. <a onclick=\’to_reply(, )\’ href= style=/>[@reply]</a>
  4. <?php
  5. }

三、在评论页后边添加”回复按钮”

  1. <?php to_reply(); ?>
    © 版权声明
    THE END
    喜欢就支持一下吧
    点赞0 分享
    评论 抢沙发

    请登录后发表评论

      暂无评论内容