상세 컨텐츠

본문 제목

[소스] 레이어 메뉴를 스크롤 시킨다.

프로그래밍/스크립트

by 라제폰 2009. 2. 6. 17:20

본문

<html>
<head>
<title> New Document </title>
</head>

<body>
<div id="objLayerRightMenu" style="position:absolute; left:934px; top:152px; z-index:3;">
<table border="1" width="200" height="200">
<tr>
 <td> 여기에 메뉴를 구현한다. </td>
</tr>
</table>
</div>

</body>
</html>
<script language="JavaScript">
<!--

 

/**************************************************************
    플래시 레이어를 스크롤 시킨다. 2006-06-06 By RahXephon
**************************************************************/
function scrollLayer(p_obj_name, p_gap_point)
{
    var start_point, end_point, timer;

    var obj_layer   = document.getElementById(p_obj_name);  // 레이어 오브젝트

    start_point = parseInt(obj_layer.style.top, 10);

    if ( start_point < p_gap_point )    start_point = p_gap_point;

    var scroll_top = document.body.scrollTop > 0 ? document.body.scrollTop : document.documentElement.scrollTop;

 end_point   = scroll_top + p_gap_point;
    limit_point = parseInt(window.document.body.scrollHeight) - parseInt(obj_layer.offsetHeight) -10;

    if ( end_point > limit_point )  end_point = limit_point;

    if ( start_point != end_point )
    {
        scroll_amount = Math.ceil( Math.abs( end_point - start_point ) / 15 );
        obj_layer.style.top = parseInt(start_point, 10) + ( ( end_point < start_point ) ? -scroll_amount : scroll_amount );
    }

    timer = window.setTimeout ("scrollLayer('" + p_obj_name + "', " + p_gap_point + ");", 1);
}

 

scrollLayer("objLayerRightMenu", 100);

//-->
</script>


관련글 더보기