Advertisement
jongsi

shake script

Aug 9th, 2011
1,377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. <style>
  2. .shakeimage{
  3. position:relative
  4. }
  5. </style>
  6. <script language="JavaScript1.2">
  7.  
  8. /*
  9. Shake image script (onMouseover)-
  10. © Dynamic Drive (www.dynamicdrive.com)
  11. For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
  12. */
  13.  
  14. //configure shake degree (where larger # equals greater shake)
  15. var rector=3
  16.  
  17. ///////DONE EDITTING///////////
  18. var stopit=0
  19. var a=1
  20.  
  21. function init(which){
  22. stopit=0
  23. shake=which
  24. shake.style.left=0
  25. shake.style.top=0
  26. }
  27.  
  28. function rattleimage(){
  29. if ((!document.all&&!document.getElementById)||stopit==1)
  30. return
  31. if (a==1){
  32. shake.style.top=parseInt(shake.style.top)+rector+"px"
  33. }
  34. else if (a==2){
  35. shake.style.left=parseInt(shake.style.left)+rector+"px"
  36. }
  37. else if (a==3){
  38. shake.style.top=parseInt(shake.style.top)-rector+"px"
  39. }
  40. else{
  41. shake.style.left=parseInt(shake.style.left)-rector+"px"
  42. }
  43. if (a<4)
  44. a++
  45. else
  46. a=1
  47. setTimeout("rattleimage()",50)
  48. }
  49.  
  50. function stoprattle(which){
  51. stopit=1
  52. which.style.left=0
  53. which.style.top=0
  54. }
  55.  
  56. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement