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에서 해주시기 바랍니다.

+
제목 글쓴이 날짜 조회
13년 전 조회 3,106
13년 전 조회 1,153
13년 전 조회 1,604
13년 전 조회 5,094
13년 전 조회 821
13년 전 조회 1,209
13년 전 조회 949
13년 전 조회 1,761
13년 전 조회 1,562
13년 전 조회 1,287
13년 전 조회 1,493
13년 전 조회 3,643
13년 전 조회 1,647
13년 전 조회 1,473
13년 전 조회 612
13년 전 조회 737
13년 전 조회 613
13년 전 조회 8,287
13년 전 조회 828
13년 전 조회 1,632
13년 전 조회 1,300
13년 전 조회 728
13년 전 조회 480
13년 전 조회 3,696
13년 전 조회 531
🐛 버그신고