그누보드5 모바일에 레이어로 Daum 우편번호 찾기 API 연동 하기.

· 11년 전 · 1688

 

관련파일 : skin/member/basic/register_form.skin.php

 

<a href="<?php echo G5_BBS_URL ?>/zip.php?frm_name=fregisterform&amp;frm_zip1=mb_zip1&amp;frm_zip2=mb_zip2&amp;frm_addr1=mb_addr1&amp;frm_addr2=mb_addr2&amp;frm_addr3=mb_addr3&amp;frm_jibeon=mb_addr_jibeon" id="reg_zip_find" class="btn_frmline win_zip_findtarget="_blank">주소 검색</a><br>


<a href="javascript:showDaumPostcode();" id="reg_zip_find" class="btn_frmline">주소 검색</a><br>

로 변경.
이때 a 태그에 들어있던 win_zip_find 클래스를 삭제하는것이 포인트 입니다.
삭제를 안하면 기존 win_zip_find click 이벤트와 충돌이 납니다.


그리고 맨 하단에 아래 자바스크립트 코드를 추가합니다.


<div id="layer" style="display:none;border:5px solid;position:fixed;width:300px;height:460px;left:50%;margin-left:-155px;top:50%;margin-top:-235px;overflow:hidden;-webkit-overflow-scrolling:touch;">
<img src="//i1.daumcdn.net/localimg/localimages/07/postcode/320/close.png" id="btnCloseLayer" style="cursor:pointer;position:absolute;right:-3px;top:-3px" onclick="closeDaumPostcode()" alt="닫기 버튼">
</div>

<script>
    // 우편번호 찾기 iframe을 넣을 element
    var element = document.getElementById('layer');

    function closeDaumPostcode() {
        // iframe을 넣은 element를 안보이게 한다.
        element.style.display = 'none';
    }

    function showDaumPostcode() {
        new daum.Postcode({
            oncomplete: function(data) {
                // 검색결과 항목을 클릭했을때 실행할 코드를 작성하는 부분.
                // 우편번호와 주소 및 영문주소 정보를 해당 필드에 넣는다.
                document.getElementById('reg_mb_zip1').value = data.postcode1;
                document.getElementById('reg_mb_zip2').value = data.postcode2;
                document.getElementById('reg_mb_addr1').value = data.address;
                document.getElementById('reg_mb_addr2').focus();
                document.getElementById('reg_mb_addr3').value = data.addressEnglish;
                // iframe을 넣은 element를 안보이게 한다.
                element.style.display = 'none';
            },
            width : '100%',
            height : '100%'
        }).embed(element);

        // iframe을 넣은 element를 보이게 한다.
        element.style.display = 'block';
    }
</script>



 

 

|
댓글을 작성하시려면 로그인이 필요합니다. 로그인

팁게시판

디자인과 관련된 유용한 정보를 공유하세요. 질문은 상단의 QA에서 해주시기 바랍니다.

+
제목 글쓴이 날짜 조회
11년 전 조회 3,511
11년 전 조회 1,115
11년 전 조회 765
11년 전 조회 2,896
11년 전 조회 1,227
11년 전 조회 645
11년 전 조회 2,932
11년 전 조회 2,829
11년 전 조회 688
11년 전 조회 3,326
11년 전 조회 810
11년 전 조회 994
11년 전 조회 1,689
11년 전 조회 949
11년 전 조회 2,427
11년 전 조회 3,034
11년 전 조회 5,712
11년 전 조회 2,062
11년 전 조회 826
11년 전 조회 1,001
11년 전 조회 876
11년 전 조회 1,372
11년 전 조회 2,167
11년 전 조회 855
11년 전 조회 1,359
🐛 버그신고