'programmer/web script'에 해당되는 글 6건

  1. 2011.08.01 [java script]Scroll menu(스크롤바 따라다니는 메뉴)


CSS
#slidemenu{position:absolute;right:5px;}

HTML
<div id="slidemenu">
<table width=85 border=0 cellpadding=0 cellspacing=0 style="border-collapse:collapse;">
<tr height=40 bgcolor='#0080ff'><td align=center valign=middle><a href="#" onclick='back_top();'><b>Top</b></a></td></tr>
<tr height=25 bgcolor='#cb97ff'><td align=center valign=middle><a href="#" onclick='FuncUpdate();'>Save</a></td></tr>
</table>
</div>
<script language=javascript>
var scroll_pixel,div_pixel,gotopos,gbpos,loop,moving_spd;
var top_margin = 145;
var top_margin2 = 145;
var speed = 10;
var speed2 = 9;
var moving_stat = 1;
function check_scrollmove()
{
 scroll_pixel = document.body.scrollTop;
 gotopos = document.body.scrollTop+top_margin;
 gbpos = document.body.scrollTop+top_margin2;
 if(slidemenu.style.pixelTop < gotopos)
 {
  moving_spd = (gbpos-slidemenu.style.pixelTop)/speed;
  slidemenu.style.pixelTop += moving_spd;
 }
 if(slidemenu.style.pixelTop > gotopos)
 {
  moving_spd = (slidemenu.style.pixelTop-gotopos)/speed;
  slidemenu.style.pixelTop -= moving_spd;
 }
 loop = setTimeout("check_scrollmove()",speed2);
}
function moving_control()
{
 if(!moving_stat)
 {
  check_scrollmove();
  moving_stat = 1;
 }
 else
 {
  clearTimeout(loop);
  moving_stat = 0;
  slidemenu.style.pixelTop = top_margin;
 }
}
check_scrollmove();

function back_top()
{
        x = document.body.scrollLeft;
        y = document.body.scrollTop;
        step = 2;
        while ((x != 0) || (y != 0)) {
                scroll (x, y);
                step += (step * step / 300);
                x -= step;
                y -= step;
                if (x < 0) x = 0;
                if (y < 0) y = 0;
        }
        scroll (0, 0);
}
 
</script>

저작자 표시
신고
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by ocsoosoo

댓글을 달아 주세요

이전버튼 1 2 3 4 5 6 이전버튼

티스토리 툴바