화면상의 객체 위치,크기 웹공부2008/04/16 12:34
<HTML>
<HEAD>
<TITLE> 화면상의 객체 위치,크기 </TITLE>
<SCRIPT LANGUAGE="JavaScript" >
<!--
function getBounds(tag)
{
var ret = new Object();
if(document.all) {
var rect = tag.getBoundingClientRect();
ret.left = rect.left + (document.documentElement.scrollLeft || document.body.scrollLeft);
ret.top = rect.top + (document.documentElement.scrollTop || document.body.scrollTop);
ret.width = rect.right - rect.left;
ret.height = rect.bottom - rect.top;
} else {
var box = document.getBoxObjectFor(tag);
ret.left = box.x;
ret.top = box.y;
ret.width = box.width;
ret.height = box.height;
}
return ret;
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<BR><BR><BR><BR><BR>
<span id="youranytag" style="border:1px solid ;width:500px;">aa</span>
<SCRIPT LANGUAGE="JavaScript">
<!--
var box = getBounds(document.getElementById('youranytag'));
var str = "left:"+box.left+"/top:"+box.top+"/width:"+box.width+"/height:"+box.height;
alert(str);
//-->
</SCRIPT>
</BODY>
</HTML>
출처 : http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=59355&page=6
참조 : http://koxo.com/lang/js/method/getBoundingClientRect.html
'웹공부' 카테고리의 다른 글
| 덧글 이모티콘 설치 - BBCode for TiStory by BLUEnLIVE (11) | 2010/05/22 |
|---|---|
| 티스토리도 포토로그 되면 좋을텐데... (6) | 2010/05/17 |
| 네이버 오픈캐스트를 블로그에 삽입해보자. (2) | 2010/05/17 |
| 태그 구름 만들기 (9) | 2010/02/01 |
| 티스토리 메뉴 펼쳐지게 하기. (6) | 2009/09/25 |
| 화면상의 객체 위치,크기 (2) | 2008/04/16 |
| prototype.js 를 위한 개발자 노트 (1) | 2008/04/16 |
| 홈페이지 레이아웃 참고용 사이트 모음 (1) | 2008/04/11 |
| 자바스크립트의 특징 (3) | 2008/04/02 |
| UI 에 대해... (0) | 2008/04/02 |
| NAVER UI Library (2) | 2008/04/02 |

















댓글을 달아 주세요
쌤~ 표준~
오랜만에 뵙네요. 잘 지내시죠?
여기다 글 남기니 누군지 알겠구만~ 난 그저그려..ㅋ.ㅋ