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,118
13년 전 조회 1,165
13년 전 조회 1,617
13년 전 조회 5,107
13년 전 조회 834
13년 전 조회 1,220
13년 전 조회 959
13년 전 조회 1,774
13년 전 조회 1,576
13년 전 조회 1,299
13년 전 조회 1,503
13년 전 조회 3,655
13년 전 조회 1,656
13년 전 조회 1,485
13년 전 조회 619
13년 전 조회 748
13년 전 조회 622
13년 전 조회 8,295
13년 전 조회 834
13년 전 조회 1,642
13년 전 조회 1,310
13년 전 조회 733
13년 전 조회 490
13년 전 조회 3,706
13년 전 조회 540