채택완료

레이어팝업 질문이요ㅠㅠ

2020-05-25 (월) 09:42:29 3,740

레이어팝업을 클릭안하고 특정 게시판 페이지 열리면 바로 뜨게하고싶은데

어떻게 수정하면될까여ㅜㅜ 도움좀 주세여..ㅜㅜ

Copy
<div style="height: 300px;"></div>

    <a href="#layer1" class="btn-example">일반 팝업레이어</a>

    <div id="layer1" class="pop-layer">

        <div class="pop-container">

            <div class="pop-conts">

                <!--content //-->

                <p class="ctxt mb20">Thank you.<br>

                    Your registration was submitted successfully.<br>

                    Selected invitees will be notified by e-mail on JANUARY 24th.<br><br>

                    Hope to see you soon!

                </p>

    

                <div class="btn-r">

                    <a href="#" class="btn-layerClose">Close</a>

                </div>

                <!--// content-->

            </div>

        </div>

    </div>


 

<script>

$('.btn-example').load(function(){

        var $href = $(this).attr('href');

        layer_popup($href);

    });

    function layer_popup(el){

 

        var $el = $(el);        //레이어의 id를 $el 변수에 저장

        var isDim = $el.prev().hasClass('dimBg');   //dimmed 레이어를 감지하기 위한 boolean 변수

 

        isDim ? $('.dim-layer').fadeIn() : $el.fadeIn();

 

        var $elWidth = ~~($el.outerWidth()),

            $elHeight = ~~($el.outerHeight()),

            docWidth = $(document).width(),

            docHeight = $(document).height();

 

        // 화면의 중앙에 레이어를 띄운다.

        if ($elHeight < docHeight || $elWidth < docWidth) {

            $el.css({

                marginTop: -$elHeight /2,

                marginLeft: -$elWidth/2

            })

        } else {

            $el.css({top: 0, left: 0});

        }

 

        $el.find('a.btn-layerClose').click(function(){

            isDim ? $('.dim-layer').fadeOut() : $el.fadeOut(); // 닫기 버튼을 클릭하면 레이어가 닫힌다.

            return false;

        });

 

        $('.layer .dimBg').click(function(){

            $('.dim-layer').fadeOut();

            return false;

        });

 

    }

 

</script>

답변 1개

채택된 답변
+20 포인트

jquery 에서 document ready 쪽에 현재 페이지를 읽어내는 $_SERVER 로 변수 선언하고 원하시는 링크로 들어왔을때 혹은 indexOf 일때 실행시키도록 하면 될것같네요..ㅎ

답변을 작성하려면 로그인이 필요합니다.