본문 바로가기

javascript

바들바들 떨고 있는 텍스트 링크

■ IE5.x

<!--1. 아래의 스크립트를 <HEAD></HEAD>사이에 복사해 넣으세요-->

<SCRIPT language="JavaScript">


var oldtext
var newtext
var newlink
var speed=10
var i_speed=1.1
var i_text=1
var timer

function startshake(thislink) {
    if (document.all) {
        newlink=eval("document.getElementById('"+thislink+"')")
        oldtext=newlink.childNodes[0].nodeValue
        shaketext()
    }
}

function shaketext() {
        if (speed<=200) {
                if (i_text<0) {newtext=oldtext+" "}
                else if (i_text>0) {newtext=" "+oldtext}
                newlink.childNodes[0].nodeValue=newtext;
                i_text=i_text*-1
                speed=speed*i_speed
                timer=setTimeout("shaketext()",speed)        
        }
        else {
                clearTimeout(timer)
                speed=20
        newlink.childNodes[0].nodeValue=oldtext;
    }
}

function stopshake() {
    if (document.all) {
                clearTimeout(timer)
                speed=20
        newlink.childNodes[0].nodeValue=oldtext;
    }
}  

</script>


</HEAD>

<!--2. <BODY> 태그내에 onload="" 혹은 onunload 부분이 있으면 복사해 넣으세요-->

<BODY BGCOLOR="#FFFFFF">

<!--3. <BODY></BODY> 부분에 아래의 스크립트를 복사해 넣으세요-->


<CENTER><P><a href="http://www.yahoo.com" name="link1" onMouseOver="startshake(this.name)" onMouseOut="stopshake()">textlink</a>

<P><a href="http://www.yahoo.com" name="link2" onMouseOver="startshake(this.name)" onMouseOut="stopshake()">textlink</a>

<P><a href="http://www.yahoo.com" name="link3" onMouseOver="startshake(this.name)" onMouseOut="stopshake()">textlink</a>

<P>텍스트 링크의 이름은 각각 다르게 설정하세요

</CENTER>