댓글 view 페이지 새로고침 해결 방법을 알고 싶어서 이렇게 질문을 올립니다.
</p>
<p><?php</p>
<p>if ( ! defined( '_GNUBOARD_' ) )</p>
<p> exit; // 개별 페이지 접근 불가</p>
<p> </p>
<p>?></p>
<p> </p>
<p><script></p>
<p> // 글자수 제한</p>
<p> var char_min = parseInt(<?php echo $comment_min ?>); // 최소</p>
<p> var char_max = parseInt(<?php echo $comment_max ?>); // 최대</p>
<p></script></p>
<p>
</p>
<p><?php if ( $is_comment_write ) {</p>
<p> if ( $w == '' )</p>
<p> $w = 'c';</p>
<p> ?></p>
<p>
</p>
<p> <!-- 댓글 쓰기 시작 { --></p>
<p> <div class="News_comments"></p>
<p> <aside id="" class=""></p>
<p> <form class="News_input" name="fviewcomment" id="fviewcomment" action="<?php echo $comment_action_url; ?>"</p>
<p> onsubmit="return fviewcomment_submit(this);" method="post" autocomplete="off"></p>
<p> <input type="hidden" name="w" value="<?php echo $w ?>" id="w"></p>
<p> <input type="hidden" name="bo_table" value="<?php echo $bo_table ?>"></p>
<p> <input type="hidden" name="wr_id" value="<?php echo $wr_id ?>"></p>
<p> <input type="hidden" name="comment_id" value="<?php echo $c_id ?>" id="comment_id"></p>
<p> <input type="hidden" name="sca" value="<?php echo $sca ?>"></p>
<p> <input type="hidden" name="sfl" value="<?php echo $sfl ?>"></p>
<p> <input type="hidden" name="stx" value="<?php echo $stx ?>"></p>
<p> <input type="hidden" name="spt" value="<?php echo $spt ?>"></p>
<p> <input type="hidden" name="page" value="<?php echo $page ?>"></p>
<p> <input type="hidden" name="is_good" value=""></p>
<p> </p>
<p> <div class="bo_vc_w_info hide"></p>
<p> <?php if ( $is_guest ) { ?></p>
<p> <label for="wr_name" class="sound_only">이름<strong> 필수</strong></label></p>
<p> <input type="text" name="wr_name" value="<?php echo get_cookie( "ck_sns_name" ); ?>" id="wr_name" required</p>
<p> class="frm_input required" size="25" placeholder="이름"></p>
<p> <label for="wr_password" class="sound_only">비밀번호<strong> 필수</strong></label></p>
<p> <input type="password" name="wr_password" id="wr_password" required class="frm_input required" size="25"</p>
<p> placeholder="비밀번호"></p>
<p> <?php echo $captcha_html; ?></p>
<p> <?php }</p>
<p> else { ?></p>
<p> <?php echo $member[ 'mb_nick' ]; ?></p>
<p> <?php } ?></p>
<p> </p>
<p> <?php if ( $board[ 'bo_use_sns' ] && ( $config[ 'cf_facebook_appid' ] || $config[ 'cf_twitter_key' ] ) ) { ?></p>
<p> <span class="sound_only">SNS 동시등록</span></p>
<p> <span id="bo_vc_send_sns"></span></p>
<p> <?php } ?></p>
<p> </div></p>
<p> <div class="News_info"></p>
<p> <span class="sound_only">내용</span></p>
<p> <textarea id="wr_content" class="News_content" name="wr_content" maxlength="10000" required class="required"</p>
<p> title="내용" placeholder="댓글내용을 입력해주세요" <?php if ( $comment_min || $comment_max ) { ?>onkeyup="check_byte('wr_content', 'char_count');" <?php } ?>><?php echo $c_wr_content; ?></textarea></p>
<p> <?php if ( $comment_min || $comment_max ) { ?></p>
<p> <script> check_byte('wr_content', 'char_count'); </script><?php } ?></p>
<p> </p>
<p> <div class="News_info_btn"></p>
<p> <?php if ( $comment_min || $comment_max ) { ?><strong id="char_cnt"><span id="char_count">0</span></p>
<p> <?php echo $comment_max; ?></p>
<p> </strong></p>
<p> <?php } ?></p>
<p> </p>
<p> <script></p>
<p> $(document).on("keyup change", "textarea#wr_content[maxlength]", function () {</p>
<p> var str = $(this).val()</p>
<p> var mx = parseInt($(this).attr("maxlength"))</p>
<p> if (str.length > mx) {</p>
<p> $(this).val(str.substr(0, mx));</p>
<p> return false;</p>
<p> }</p>
<p> });</p>
<p> </script></p>
<p> <button type="submit" id="btn_submit" class="btn btn_cmt_submit News_submit">등록</button></p>
<p> </div></p>
<p> </div></p>
<p> </form></p>
<p> </aside></p>
<p> <script></p>
<p> const News_content = document.querySelector('.News_content');</p>
<p> </p>
<p> </script></p>
<p> <script></p>
<p> var save_before = '';</p>
<p> var save_html = document.getElementById('bo_vc_w').innerHTML;</p>
<p> </p>
<p> function good_and_write() {</p>
<p> var f = document.fviewcomment;</p>
<p> if (fviewcomment_submit(f)) {</p>
<p> f.is_good.value = 1;</p>
<p> f.submit();</p>
<p> } else {</p>
<p> f.is_good.value = 0;</p>
<p> }</p>
<p> }</p>
<p> </p>
<p> function fviewcomment_submit(f) {</p>
<p> var pattern = /(^\s*)|(\s*$)/g; // \s 공백 문자</p>
<p> </p>
<p> f.is_good.value = 0;</p>
<p> </p>
<p> var subject = "";</p>
<p> var content = "시발";</p>
<p> $.ajax({</p>
<p> url: g5_bbs_url + "/ajax.filter.php",</p>
<p> type: "POST",</p>
<p> data: {</p>
<p> "subject": "",</p>
<p> "content": f.wr_content.value</p>
<p> },</p>
<p> dataType: "json",</p>
<p> async: false,</p>
<p> cache: false,</p>
<p> success: function (data, textStatus) {</p>
<p> subject = data.subject;</p>
<p> content = data.content;</p>
<p> }</p>
<p> });</p>
<p> </p>
<p> if (content) {</p>
<p> alert("내용에 금지단어('" + content + "')가 포함되어있습니다");</p>
<p> f.wr_content.focus();</p>
<p> return false;</p>
<p> }</p>
<p> </p>
<p> // 양쪽 공백 없애기</p>
<p> var pattern = /(^\s*)|(\s*$)/g; // \s 공백 문자</p>
<p> document.getElementById('wr_content').value = document.getElementById('wr_content').value.replace(pattern, "");</p>
<p> if (char_min > 0 || char_max > 0) {</p>
<p> check_byte('wr_content', 'char_count');</p>
<p> var cnt = parseInt(document.getElementById('char_count').innerHTML);</p>
<p> if (char_min > 0 && char_min > cnt) {</p>
<p> alert("댓글은 " + char_min + "글자 이상 쓰셔야 합니다.");</p>
<p> return false;</p>
<p> } else if (char_max > 0 && char_max < cnt) {</p>
<p> alert("댓글은 " + char_max + "글자 이하로 쓰셔야 합니다.");</p>
<p> return false;</p>
<p> }</p>
<p> }</p>
<p> else if (!document.getElementById('wr_content').value) {</p>
<p> alert("댓글을 입력하여 주십시오.");</p>
<p> return false;</p>
<p> }</p>
<p> </p>
<p> if (typeof (f.wr_name) != 'undefined') {</p>
<p> f.wr_name.value = f.wr_name.value.replace(pattern, "");</p>
<p> if (f.wr_name.value == '') {</p>
<p> alert('이름이 입력되지 않았습니다.');</p>
<p> f.wr_name.focus();</p>
<p> return false;</p>
<p> }</p>
<p> }</p>
<p> </p>
<p> if (typeof (f.wr_password) != 'undefined') {</p>
<p> f.wr_password.value = f.wr_password.value.replace(pattern, "");</p>
<p> if (f.wr_password.value == '') {</p>
<p> alert('비밀번호가 입력되지 않았습니다.');</p>
<p> f.wr_password.focus();</p>
<p> return false;</p>
<p> }</p>
<p> }</p>
<p> </p>
<p> <?php if ( $is_guest )</p>
<p> echo chk_captcha_js(); ?></p>
<p> </p>
<p> set_comment_token(f);</p>
<p> </p>
<p> document.getElementById("btn_submit").disabled = "disabled";</p>
<p> </p>
<p> return true;</p>
<p> }</p>
<p> </p>
<p> function comment_box(comment_id, work) {</p>
<p> var el_id,</p>
<p> form_el = 'fviewcomment',</p>
<p> respond = document.getElementById(form_el);</p>
<p> </p>
<p> // 댓글 아이디가 넘어오면 답변, 수정</p>
<p> if (comment_id) {</p>
<p> if (work == 'c')</p>
<p> el_id = 'reply_' + comment_id;</p>
<p> }</p>
<p> else</p>
<p> el_id = 'bo_vc_w';</p>
<p> </p>
<p> if (save_before != el_id) {</p>
<p> if (save_before) {</p>
<p> document.getElementById(save_before).style.display = 'none';</p>
<p> }</p>
<p> const News_info = document.querySelector('.News_info');</p>
<p> document.getElementById(el_id).style.display = '';</p>
<p> document.getElementById(el_id).appendChild(respond);</p>
<p> News_info.classList.add('News_answer');</p>
<p> //입력값 초기화</p>
<p> document.getElementById('wr_content').value = '';</p>
<p> document.getElementById('wr_content').value = '';</p>
<p> </p>
<p> document.getElementById('comment_id').value = comment_id;</p>
<p> document.getElementById('w').value = work;</p>
<p> </p>
<p> if (save_before)</p>
<p> $("#captcha_reload").trigger("click");</p>
<p> </p>
<p> save_before = el_id;</p>
<p> } else if (comment_id) {</p>
<p> comment_box('', 'c');</p>
<p> }</p>
<p> </p>
<p> }</p>
<p> </p>
<p> function comment_delete() {</p>
<p> return confirm("이 댓글을 삭제하시겠습니까?");</p>
<p> }</p>
<p> </p>
<p> comment_box('', 'c'); // 댓글 입력폼이 보이도록 처리하기위해서 추가 (root님)</p>
<p> </p>
<p> <?php if ( $board[ 'bo_use_sns' ] && ( $config[ 'cf_facebook_appid' ] || $config[ 'cf_twitter_key' ] ) ) { ?></p>
<p> </p>
<p> $(function () {</p>
<p> // sns 등록</p>
<p> $("#bo_vc_send_sns").load(</p>
<p> "<?php echo G5_SNS_URL; ?>/view_comment_write.sns.skin.php?bo_table=<?php echo $bo_table; ?>",</p>
<p> function () {</p>
<p> save_html = document.getElementById('bo_vc_w').innerHTML;</p>
<p> }</p>
<p> );</p>
<p> });</p>
<p> <?php } ?></p>
<p> </script></p>
<p> <script></p>
<p> </p>
<p> </script></p>
<p> <!-- } 댓글 쓰기 끝 --></p>
<p> <?php }</p>
<p>else { ?></p>
<p> <aside id="bo_vc_login" class="bo_vc_login"></p>
<p> <a href="<?php echo G5_BBS_URL ?>/login.php">로그인 해주세요.</a></p>
<p> </aside></p>
<p> <?php } ?></p>
<p> <!-- } 댓글 쓰기 끝 --></p>
<p>
</p>
<p> <!-- 댓글 시작 { --></p>
<p> <section class="NewsComment" id="bo_vc"></p>
<p> <?php</p>
<p> $cmt_amt = count( $list );</p>
<p> for ( $i = 0; $i < $cmt_amt; $i++ ) {</p>
<p> $comment_id = $list[ $i ][ 'wr_id' ];</p>
<p> $cmt_depth = strlen( $list[ $i ][ 'wr_comment_reply' ] ) * 20;</p>
<p> $cmt_answer = strlen( $list[ $i ][ 'wr_comment_reply' ] ) * 40;</p>
<p> $comment = $list[ $i ][ 'content' ];</p>
<p> /*</p>
<p> if (strstr($list[$i]['wr_option'], "secret")) {</p>
<p> $str = $str;</p>
<p> }</p>
<p> */</p>
<p> $comment = preg_replace( "/\[\<a\s.*href\=\"(http|https|ftp|mms)\:\/\/([^[:space:]]+)\.(mp3|wma|wmv|asf|asx|mpg|mpeg)\".*\<\/a\>\]/i", "<script>doc_write(obj_movie('$1://$2.$3'));</script>", $comment );</p>
<p> $cmt_sv = $cmt_amt - $i + 1; // 댓글 헤더 z-index 재설정 ie8 이하 사이드뷰 겹침 문제 해결</p>
<p> $c_reply_href = $comment_common_url . '&c_id=' . $comment_id . '&w=c#bo_vc_w';</p>
<p> $c_edit_href = $comment_common_url . '&c_id=' . $comment_id . '&w=cu#bo_vc_w';</p>
<p> $is_comment_reply_edit = ( $list[ $i ][ 'is_reply' ] || $list[ $i ][ 'is_edit' ] || $list[ $i ][ 'is_del' ] ) ? 1 : 0;</p>
<p> ?></p>
<p> </p>
<p> <article id="c_<?php echo $comment_id ?>" <?php if ( $cmt_depth ) { ?>style="margin-left:<?php echo $cmt_depth; ?>px;" <?php } ?>></p>
<p> <div></p>
<p> <div class="News_profile"></p>
<p> <div class="pf_img"></p>
<p> <?php echo get_member_profile_img( $list[ $i ][ 'mb_id' ] ); ?></p>
<p> <?php echo get_text( $list[ $i ][ 'wr_name' ] ); ?></p>
<p> <span class="bo_vc_hdinfo">작성일 :</p>
<p> <?php echo $list[ $i ][ 'datetime' ] ?></p>
<p> </span></p>
<p> </div></p>
<p> <ul class="bo_vc_act"></p>
<p> <li></p>
<p> <a class="good_btn"</p>
<p> href="<?php echo G5_BBS_URL . '/good.php?bo_table=' . $bo_table . '&wr_id=' . $list[ $i ][ 'wr_id' ] . '&good=good'; ?>"></p>
<p> <img class="" src="<?php echo $board_skin_url; ?>/img/like.png"><strong style="margin-left:10px"></p>
<p> <?php echo number_format( $list[ $i ][ 'wr_good' ] ) ?></p>
<p> </strong></p>
<p> <b id="bo_v_act_good" class="bo_v_act_good"></b></p>
<p> </a></p>
<p> </li></p>
<p> </ul></p>
<p> </div></p>
<p> </p>
<p> <div class="cm_wrap"></p>
<p> </p>
<p> <!-- 댓글 출력 --></p>
<p> <div class="contentsBox"></p>
<p> <p></p>
<p> <?php if ( strstr( $list[ $i ][ 'wr_option' ], "secret" ) ) { ?><i class="xi-lock xi-x"></i></p>
<p> <?php } ?></p>
<p> <?php echo $comment ?></p>
<p> </p></p>
<p> <?php if ( $is_comment_reply_edit ) {</p>
<p> if ( $w == 'cu' ) {</p>
<p> $sql = " select wr_id, wr_content, mb_id from $write_table where wr_id = '$c_id' and wr_is_comment = '1' ";</p>
<p> $cmt = sql_fetch( $sql );</p>
<p> </p>
<p> if ( ! ( $is_admin || ( $member[ 'mb_id' ] == $cmt[ 'mb_id' ] && $cmt[ 'mb_id' ] ) ) )</p>
<p> $cmt[ 'wr_content' ] = '';</p>
<p> $c_wr_content = $cmt[ 'wr_content' ];</p>
<p> }</p>
<p> ?></p>
<p> <?php } ?></p>
<p> <input type="hidden" value="<?php echo strstr( $list[ $i ][ 'wr_option' ], "secret" ) ?>"</p>
<p> id="secret_comment_<?php echo $comment_id ?>"></p>
<p> <textarea id="save_comment_<?php echo $comment_id ?>"</p>
<p> style="display:none"><?php echo get_text( $list[ $i ][ 'content1' ], 0 ) ?></textarea></p>
<p> </div></p>
<p> </p>
<p> <?php if ( $is_comment_reply_edit ) { ?></p>
<p> <div class="bo_vl_opt"></p>
<p> <button type="button" class="btn_cm_opt hide"></p>
<p> <i class="xi-ellipsis-v xi-x"></i></p>
<p> <span class="sound_only">댓글 옵션</span></p>
<p> </button></p>
<p> <ul class="bo_vc_act hide"></p>
<p> <?php if ( $list[ $i ][ 'is_reply' ] ) { ?></p>
<p> <li><a href="<?php echo $c_reply_href; ?>"</p>
<p> onclick="comment_box('<?php echo $comment_id ?>', 'c'); return false;">답변</a></li></p>
<p> <?php } ?></p>
<p> <?php if ( $list[ $i ][ 'is_edit' ] ) { ?></p>
<p> <li><a href="<?php echo $c_edit_href; ?>"</p>
<p> onclick="comment_box('<?php echo $comment_id ?>', 'cu'); return false;">수정</a></li></p>
<p> <?php } ?></p>
<p> <?php if ( $list[ $i ][ 'is_del`' ] ) { ?></p>
<p> <li><a href="<?php echo $list[ $i ][ 'del_link' ]; ?>" onclick="return comment_delete();">삭제</a></li></p>
<p> <?php } ?></p>
<p> </ul></p>
<p> </div></p>
<p> <?php } ?></p>
<p> </div></p>
<p> </div></p>
<p> <div class="comment_down"></p>
<p> <?php if ( $list[ $i ][ 'is_reply' ] ) { ?></p>
<p> <p><a href="<?php echo $c_reply_href; ?>"</p>
<p> onclick="comment_box('<?php echo $comment_id ?>', 'c'); return false;">답변</a></p></p>
<p> <?php } ?></p>
<p> </div></p>
<p> </article></p>
<p> <div id="reply_<?php echo $comment_id ?>" class="bo_vc_w" <?php if ( $cmt_answer ) { ?>style="margin-left:<?php echo $cmt_answer; ?>px;" <?php } ?>></div><!-- 답변 --></p>
<p> <?php } ?></p>
<p> <?php if ( $i == 0 ) { //댓글이 없다면 ?></p>
<p> <p id="bo_vc_empty">등록된 댓글이 없습니다.</p></p>
<p> <?php } ?></p>
<p> </p>
<p> </section></p>
<p></div></p>
<p><!-- } 댓글 끝 --></p>
<p>
이 코드에서
function comment_box(comment_id, work) {
var el_id,
form_el = 'fviewcomment',
respond = document.getElementById(form_el);
// 댓글 아이디가 넘어오면 답변, 수정
if (comment_id) {
if (work == 'c')
el_id = 'reply_' + comment_id;
}
else
el_id = 'bo_vc_w';
if (save_before != el_id) {
if (save_before) {
document.getElementById(save_before).style.display = 'none';
}
const News_info = document.querySelector('.News_info');
document.getElementById(el_id).style.display = '';
document.getElementById(el_id).appendChild(respond);
News_info.classList.add('News_answer');
//입력값 초기화
document.getElementById('wr_content').value = '';
document.getElementById('wr_content').value = '';
document.getElementById('comment_id').value = comment_id;
document.getElementById('w').value = work;
if (save_before)
$("#captcha_reload").trigger("click");
save_before = el_id;
} else if (comment_id) {
comment_box('', 'c');
}
부분입니다
https://sir.kr/g5_tip/13322 사이트에서 답글을 누르면 다시 취소되는 기능이 였는데 지금 제 사이트에는 새로고침이 되는 현상이 있어서 질문을 올립니다
답변을 작성하려면 로그인이 필요합니다.
로그인