Bottoni che tremano al passaggio del mouse
Con questo DHTML si possono creare degli ottimi menù,inserendo dei bottoni che vibreranno al passaggio del mousesopra di essi.
Il primo passo consiste nell'inserire questo codiceall'interno del tag head:
<style>.shakeimage{position:relative}</style><script language="JavaScript1.2">/*Shake image script (onMouseover)- © Dynamic Drive (www.dynamicdrive.com)For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com*///configure shake degree (where larger # equals greater shake)var rector=3///////DONE EDITTING///////////var stopit=0 var a=1function init(which){stopit=0shake=whichshake.style.left=0shake.style.top=0}function rattleimage(){if ((!document.all&&!document.getElementById)||stopit==1)returnif (a==1){shake.style.top=parseInt(shake.style.top)+rector}else if (a==2){shake.style.left=parseInt(shake.style.left)+rector}else if (a==3){shake.style.top=parseInt(shake.style.top)-rector}else{shake.style.left=parseInt(shake.style.left)-rector}if (a<4)a++elsea=1setTimeout("rattleimage()" ,50)}function stoprattle(which){stopit=1which.style.left=0which.style.top=0}</script>
Adesso basterà inserire questo codice all'internodel tag img utilizzato per le immagini che dovrannovibrare:
class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus()"
- Articolo precedente Inserire degli occhi che 'seguono con lo sguardo' il puntatore del mouse
- Articolo successivo Logo statico fisso sullo schermo