Advertisement
invaderzim

wobble text

Jun 26th, 2022 (edited)
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2. // <![CDATA[
  3. var speed=100; // speed of wobbling, lower is faster
  4. var height=3; // height of wobbling in pixels
  5. var alink=""; // page to link text to (set to ="" for no link)
  6.  
  7. /****************************
  8. * Wobbly Text Effect *
  9. *(c) 2003-6 mf2fm web-design*
  10. * http://www.mf2fm.com/rv *
  11. * DON'T EDIT BELOW THIS BOX *
  12. ****************************/
  13. var wobtxt, wobble, wobcnt=0;
  14. window.onload=function() { if (document.getElementById) {
  15. var i, wobli;
  16. wobble=document.getElementById("wobble");
  17. wobtxt=wobble.firstChild.nodeValue;
  18. while (wobble.childNodes.length) wobble.removeChild(wobble.childNodes[0]);
  19. for (i=0; i<wobtxt.length; i++) {
  20. wobli=document.createElement("span");
  21. wobli.setAttribute("id", "wobb"+i);
  22. wobli.style.position="relative";
  23. wobli.appendChild(document.createTextNode(wobtxt.charAt(i)));
  24. if (alink) {
  25. wobli.style.cursor="pointer";
  26. wobli.onclick=function() { top.location.href=alink; }
  27. }
  28. wobble.appendChild(wobli);
  29. }
  30. setInterval("wobbler()", speed);
  31. }}
  32.  
  33. function wobbler() {
  34. for (var i=0; i<wobtxt.length; i++) document.getElementById("wobb"+i).style.top=Math.round(height*Math.sin(i+wobcnt))+"px"
  35. wobcnt++;
  36. }
  37. // ]]>
  38. </script>
  39. <div id="wobble" style="font-size:1.25em;
  40. line-height:1.75em;
  41. font-family:'arial';
  42. color:#000;">wobble</div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement