JS實(shí)現(xiàn)把鼠標(biāo)放到鏈接上出現(xiàn)滾動(dòng)文字的方法

字號(hào):


    本文實(shí)例講述了JS實(shí)現(xiàn)把鼠標(biāo)放到鏈接上出現(xiàn)滾動(dòng)文字的方法。分享給大家供大家參考,具體如下:
    <div id="tooltip2">
    <layer name="nstip" width=1000px bgColor="seashell"></layer>
    </div>
    <SCRIPT language="JavaScript">
    <!--
    if (!document.layers&&!document.all)
    event="test"
    function showtip2(current,e,text){
    if (document.all&&document.readyState=="complete"){
    document.all.tooltip2.innerHTML='<marquee>'+text+'</marquee>'
    document.all.tooltip2.style.pixelLeft=event.clientX+document.body.scrollLeft+10
    document.all.tooltip2.style.pixelTop=event.clientY+document.body.scrollTop+10
    document.all.tooltip2.style.visibility="visible"
    }
    else if (document.layers){
    document.tooltip2.document.nstip.document.write('<b>'+text+'</b>')
    document.tooltip2.document.nstip.document.close()
    document.tooltip2.document.nstip.left=0
    currentscroll=setInterval("scrolltip()",100)
    document.tooltip2.left=e.pageX+10
    document.tooltip2.top=e.pageY+10
    document.tooltip2.visibility="show"
    }
    }
    function hidetip2(){
    if (document.all)
    document.all.tooltip2.style.visibility="hidden"
    else if (document.layers){
    clearInterval(currentscroll)
    document.tooltip2.visibility="hidden"
    }
    }
    function scrolltip(){
    if (document.tooltip2.document.nstip.left>=-document.tooltip2.document.nstip.document.width)
    document.tooltip2.document.nstip.left-=5
    else
    document.tooltip2.document.nstip.left=150
    }
    //--> 
    </SCRIPT>
    <a href=# onMouseOver="showtip2(this,event,'看到了吧?')" onMouseOut="hidetip2()">把鼠標(biāo)放上來試試</a>
    希望本文所述對(duì)大家JavaScript程序設(shè)計(jì)有所幫助。