[JS] 스크롤메뉴
IE6 이상에서 DTD를 지정하여 사용할 경우 document.body 대신 document.documentElement를 사용해야 합니다.
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
와 같이 dtd를 지정한 경우에 document.body를 인식하지 못하기 때문에 수정한 소스입니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <!-- var min = 89; // 레이어 top 초기 값 (레이어 top 값과 일치시킴) var max = 0; var moving_speed = 10 // 속도(낮을 수록 빠름) var moving_amount = 10 // 움직임 (낮을 수록 부드러움) var action_time = 500 // 반응시간 (*/1000 초 후에 반응) function left_move_init() { itm = document.getElementById("quickmenu"); itm.set_pos = function(y){itm.style.top=y+"px";}; itm.y = min; itm.set_pos(itm.y); max = document.documentElement.scrollHeight - itm.scrollHeight - min; setTimeout(left_move_func, moving_amount); } function left_move_func() { itm = document.getElementById("quickmenu"); tmp = document.documentElement.scrollTop + min; itm.y += Math.floor((tmp-itm.y)/moving_speed); if( itm.y>max ) itm.y = max; if( itm.y<min ) itm.y = min; itm.set_pos(itm.y); setTimeout(left_move_func, moving_amount); } setTimeout(left_move_init, action_time); //--> |


