c

클릭위치로 레이어 띄우기

게시판등에서 닉네임 클릭시 X값과 Y값을 계산해서 클릭위치에서 레이어를 띄워주는
소스를 사용하고 있습니다.
구글링을 하여 괜찮은 소스를 사용하고 있는데요
클릭지점마다 조금씩 위치가 바뀌게 하지 않고 위치 지점이 고정되게끔 해주고 싶은데
방법을 모르겠네요
<script type="text/javascript">
function abspos(e){
    this.x = e.clientX + (document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
    this.y = e.clientY + (document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
    return this;
}

function itemClick(e){
    var ex_obj = document.getElementById('lay');
    if(!e) e = window.Event;
    pos = abspos(e);
    ex_obj.style.left = pos.x+"px";
    ex_obj.style.top = (pos.y+10)+"px";
    ex_obj.style.display = ex_obj.style.display=='none'?'block':'none';
}
</script>
 
<div id="lay" style="position:absolute; display:none;">내용이 어쩌고 저쩌고</div>
<div style="padding:300px 0 0 200px;"><input type="button" onclick="itemClick(event);" value="클릭"></div>
 
여기서 어떻게 수정해야 할까요? 아시는 분 계시면 정중하게 부탁좀 드리겠습니다
개발자가 아니라 수정하기가 참 힘이 드네요
|

댓글 1개

ex_obj.style.left = pos.x+"px";
ex_obj.style.top = (pos.y+10)+"px";
이부분을
ex_obj.style.left = "100px";
ex_obj.style.top = "100px";
이렇게 해주면 되지 않을까용?
댓글을 작성하시려면 로그인이 필요합니다.

팁게시판

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

+
제목 글쓴이 날짜 조회
14년 전 조회 3,140
14년 전 조회 1,192
14년 전 조회 1,643
14년 전 조회 5,128
14년 전 조회 856
14년 전 조회 1,248
14년 전 조회 983
14년 전 조회 1,797
14년 전 조회 1,599
14년 전 조회 1,321
14년 전 조회 1,528
14년 전 조회 3,678
14년 전 조회 1,683
14년 전 조회 1,510
14년 전 조회 646
14년 전 조회 771
14년 전 조회 644
14년 전 조회 8,321
14년 전 조회 862
14년 전 조회 1,672
14년 전 조회 1,337
14년 전 조회 762
14년 전 조회 518
14년 전 조회 3,730
14년 전 조회 562