applepik

wobbly text

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