c

클릭위치로 레이어 띄우기

· 2012-03-08 (목) 09:11:31 · 3358 · 1
게시판등에서 닉네임 클릭시 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개

2012-03-08 (목) 10:36:53
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";
이렇게 해주면 되지 않을까용?
댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

5,403건

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
OS 23-03-13 조회 1,570
웹서버 23-03-13 조회 1,685
웹서버 23-03-13 조회 1,824
PHP 23-03-13 조회 1,633
PHP 23-03-13 조회 1,656
PHP 23-03-13 조회 1,666
PHP 23-03-13 조회 1,612
PHP 23-02-23 조회 1,624
JavaScript 23-02-23 조회 1,672
PHP 23-02-23 조회 2,529
웹서버 23-02-23 조회 1,614
PHP 23-02-23 조회 1,768
PHP 23-02-21 조회 1,619
node.js 23-02-15 조회 2,102
OS 23-02-10 조회 2,315
웹서버 23-02-08 조회 1,662
PHP 23-02-07 조회 7,977
JavaScript 23-01-31 조회 2,497
PHP 23-01-26 조회 1,680
PHP 23-01-03 조회 2,327
JavaScript 23-01-02 조회 1,572
PHP 23-01-02 조회 1,677
웹서버 22-12-14 조회 3,316
기타 22-11-29 조회 2,324
JavaScript 22-11-24 조회 1,981
PHP 22-11-07 조회 2,304
MySQL 22-11-01 조회 2,482
PHP 22-10-31 조회 2,755
PHP 22-10-16 조회 2,799
JavaScript
[JavaScript]
22-10-04 조회 1,849