Advertisement
BhieNEka

Shakeimages.js

Apr 27th, 2013
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var type="a",rector=3,stopit=0,a=1;
  2. function init(which){
  3. stopit=0;shake=which;shake.style.left=0;shake.style.top=0;
  4. }
  5. function rattleimage(){
  6. if((!document.all&&!document.getElementById)||stopit==1)return;
  7. if(a==1)shake.style.top=parseInt(shake.style.top)+rector+"px";
  8. else if(a==2)shake.style.left=parseInt(shake.style.left)+rector+"px";
  9. else if(a==3)shake.style.top=parseInt(shake.style.top)-rector+"px";
  10. else shake.style.left=parseInt(shake.style.left)-rector+"px";
  11. if(a<4)a++;
  12. else a=1;
  13. setTimeout("rattleimage()",50)
  14. }
  15. function stoprattle(which){
  16. stopit=1;
  17. which.style.left=0;
  18. which.style.top=0
  19. }
  20. function shakeit(){
  21. link=document.getElementsByTagName(type);
  22. for(i=0;i<link.length;i++){
  23. link[i].style.position="relative";
  24. link[i].onmouseover=function(){init(this);rattleimage()};
  25. link[i].onmouseout=function(){stoprattle(this);top.focus()}
  26. }
  27. }
  28. if(window.addEventListener)window.addEventListener("load",shakeit,false);
  29. else if(window.attachEvent)window.attachEvent("onload",shakeit);
  30. else if(document.getElementById)window.onload=shakeit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement