Javascript: webpage special effects: Sliding and folding effects, Javascript tutorial
You need to write a slide, expand, and collapse effect. You can find a post of the carefree script and make it be applied to FF with a slight modification. The Code is as follows:
The following is a reference clip: // Url: http://bbs.51js.com/thread-61646-1-1.html // Author: sudden changes // Modify: fengyan Var act; Function over (s, nMax ){ Var obj = document. getElementById (s ); Var h = parseInt (obj. offsetHeight ); If (h <nMax ){ Obj. style. height = (h + 2) + "px "; ClearTimeout (act ); Act = setTimeout ("over ('" + s + "'," + nMax + ")", 10 ); } } Function out (s, nMin ){ Var obj = document. getElementById (s ); Var h = parseInt (obj. offsetHeight ); If (h> nMin ){ Obj. style. height = (h-2) + "px "; ClearTimeout (act ); Act = setTimeout ("out ('" + s + "'," + nMin + ")", 10 ); } } Script <Div id = "mytd" onmouseover = "over ('mytd ', 200);" onmouseout = "out ('mytd', 30);" style = "background: # eee; "> code instance: slide expansion/collapse of Layers |
Carefree netizensFangxiao9159After optimization:
The following is a reference clip: Var intervalId = null; Function move (id, state ){ Var obj = document. getElementById (id ); If (intervalId! = Null) Window. clearInterval (intervalId ); Function change (){ Var h = parseInt (obj. offsetHeight ); Obj. style. height = (state = "down ")? (H + 2): (h-2 ); } IntervalId = window. setInterval (change, 10 ); } Script |
Worry-free script-sudden changes |