티스토리 툴바

상단이동
처음화면
모아보기
무비툰
일기
요리
그림
사진
잡생각
방명록
미류
관리자
글쓰기

달력

05

« 2013/05 »

  •  
  •  
  •  
  • 1
  • 2
  • 3
  • 4
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  •  
2008/04/16 12:34

화면상의 객체 위치,크기 웹공부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>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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

크리에이티브 커먼즈 라이선스
Creative Commons License
하로기의 무비툰

하로기의 무비툰

글/그림
하로기
형식/장르
공포
작품소개
영화를 보고 느낀 것들을 일기 형식으로 만든 웹툰입니다. 주로 B급공포장르가 많아요~


Posted by 하로기
익명이지만 적어도 자신만의 닉네임으로 글을 남겨주세요. 아무 의미없어 보이는 기호나 이모티콘등으로 대충 쓴 덧글은 보기 좋지 않습니다. 덧글 또한 상호 의사소통입니다. 상호간의 매너...원츄~

TRACKBACK | http://movietoon.net/trackback/947 관련글 쓰기

댓글을 달아 주세요

  1. 뫼루 2009/07/21 02:33  댓글주소  수정/삭제  댓글쓰기

    쌤~ 표준~
    오랜만에 뵙네요. 잘 지내시죠?