좌우버튼 마우스오버시 픽셀단위로 이동하는 소스

 

 펌 : http://www.wepas.com/bbs/zboard.php?id=javascript&page=8&sn1=&divpage=1&sn=off&ss=on&sc=on&select_arrange=subject&desc=desc&no=58&PHPSESSID=2ed321008d7d602fd08e655bdb21b71b#

 

 실행화면

scroll_6.png

 

 

<script type="text/javascript">
var menuwidth=340
var menuheight=20
var scrolldir="normal"
var scrollspeed=6
var menucontents='<nobr><a href="http://www.wepas.comhttp://www.wepas.com">http://www.wepas.com</a> | <a href="http://www.naver.comhttp://www.naver.com">http://www.naver.com</a> | <a href="http://www.empas.comhttp://www.empas.com">http://www.empas.com</a> | <a href="http://www.google.co.krhttp://www.google.co.kr">http://www.google.co.kr</a> | <a href="http://www.nate.com">http://www.nate.com">http://www.nate.com</a></nobr>'


var iedom=document.all||document.getElementById
var leftdircode='onMouseover="moveleft()" onMouseout="clearTimeout(lefttime)"'
var rightdircode='onMouseover="moveright()" onMouseout="clearTimeout(righttime)"'
        if (scrolldir=="reverse"){
var tempswap=leftdircode
        leftdircode=rightdircode
        rightdircode=tempswap
        }
        if (iedom)
                document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-5000">'+menucontents+'</span>')
var actualwidth=''
var cross_scroll, ns_scroll
var loadedyes=0

function fillup(){
        if (iedom){
                cross_scroll=document.getElementById? document.getElementById("test2") : document.all.test2
                cross_scroll.innerHTML=menucontents
                actualwidth=document.all? cross_scroll.offsetWidth : document.getElementById("temp").offsetWidth
        }
        else if (document.layers){
                ns_scroll=document.ns_scrollmenu.document.ns_scrollmenu2
                ns_scroll.document.write(menucontents)
                ns_scroll.document.close()
                actualwidth=ns_scroll.document.width
        }
        loadedyes=1
        }
window.onload=fillup

function moveleft(){
        if (loadedyes){
        if (iedom&&parseInt(cross_scroll.style.left)>(menuwidth-actualwidth)){
                cross_scroll.style.left=parseInt(cross_scroll.style.left)-scrollspeed+"px"
        }
        else if (document.layers&&ns_scroll.left>(menuwidth-actualwidth))
                ns_scroll.left-=scrollspeed
        }
                lefttime=setTimeout("moveleft()",50)
}

function moveright(){
        if (loadedyes){
        if (iedom&&parseInt(cross_scroll.style.left)<0)
                cross_scroll.style.left=parseInt(cross_scroll.style.left)+scrollspeed+"px"
        else if (document.layers&&ns_scroll.left<0)
                ns_scroll.left+=scrollspeed
        }
        righttime=setTimeout("moveright()",50)
        }

        if (iedom||document.layers){
                with (document){
                        write('<table border="0" cellspacing="0" cellpadding="2">')
                        write('<td valign="middle"><a href="#" '+leftdircode+'>◀</a> </td>')
                        write('<td width="'+menuwidth+'px" valign="top">')
        if (iedom){
                write('<div style="position:relative;width:'+menuwidth+'px;height:'+menuheight+'px;overflow:hidden;">')
                write('<div id="test2" style="position:absolute;left:0;top:0">')
                write('</div></div>')
        }
        else if (document.layers){
                write('<ilayer width='+menuwidth+' height='+menuheight+' name="ns_scrollmenu">')
                write('<layer name="ns_scrollmenu2" left=0 top=0></layer></ilayer>')
                }
                write('</td>')
                write('<td valign="middle"> <a href="#" '+rightdircode+'>')
                write('▶</a>')
                write('</td></table>')
        }
}
</script>