독도 광고 모금 캠페인

<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

이올린에 북마크하기(0) 이올린에 추천하기(0)

'JavaSCript' 카테고리의 다른 글

화면상의 객체 위치,크기  (0) 2008/04/16
prototype.js 를 위한 개발자 노트  (1) 2008/04/16
자바스크립트의 특징  (1) 2008/04/02
@cc_on  (0) 2008/03/24
레이어 드래그 + 투명효과  (2) 2008/03/24
자바스크립트 에러 출력방지  (0) 2008/03/13
Posted by 하로기

트랙백 주소 :: http://harogipro.tistory.com/trackback/192 관련글 쓰기

댓글을 달아 주세요