Advertisement
kyujouz

news ticker w/ pixel

Mar 10th, 2024
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. <style>#news { font-size:1.5em;font-family: lovely;display: inline-block;color: #854234;}</style>
  2. <span id="news"></span><a href="https://www.w3schools.com/code/tryit.asp?filename=GVLM8GCGG1AP"><img class=pixel src="https://enchantments.carrd.co/assets/images/gallery04/49430ffb.gif?v=e51d30af"></a>
  3.  
  4. <script type="text/javascript">
  5. // <![CDATA[
  6. var news=Array("ticker","pixel");
  7. var cursor=""; // set cursor
  8. var delay=2; // seconds between each news item
  9.  
  10. /***************************\
  11. * News Ticker Text Effect *
  12. *(c)2004-14 mf2fm web-design*
  13. * http://www.mf2fm.com/rv *
  14. * DON'T EDIT BELOW THIS BOX *
  15. \***************************/
  16. var newsp, cursp, flash, item=0;
  17.  
  18. if (typeof('addRVLoadEvent')!='function') function addRVLoadEvent(funky) {
  19. var oldonload=window.onload;
  20. if (typeof(oldonload)!='function') window.onload=funky;
  21. else window.onload=function() {
  22. if (oldonload) oldonload();
  23. funky();
  24. }
  25. }
  26.  
  27. addRVLoadEvent(teleprint);
  28.  
  29. function teleprint () { if (document.getElementById) {
  30. var span=document.getElementById("news");
  31. while (span.childNodes.length) span.removeChild(span.childNodes[0]);
  32. delay*=1000;
  33. newsp=document.createElement("span");
  34. cursp=document.createElement("span");
  35. cursp.appendChild(document.createTextNode(String.fromCharCode(160)+cursor));
  36. span.appendChild(newsp);
  37. span.appendChild(cursp);
  38. ticker();
  39. }}
  40.  
  41. function ticker() {
  42. var i;
  43. while (newsp.childNodes.length) newsp.removeChild(newsp.childNodes[0]);
  44. newsp.appendChild(document.createTextNode(news[item].substring(0,1)));
  45. for (i=1; i<news[item].length; i++) setTimeout('newsp.firstChild.nodeValue="'+news[item].substring(0, i+1)+'"', 100*i);
  46. if (news[item].indexOf("www")!=-1) setTimeout('linkit('+item+')', 100*i);
  47. setTimeout('flash=setInterval("cursp.style.visibility=(cursp.style.visibility==\'visible\')?\'hidden\':\'visible\'", 234)', 100*i)
  48. setTimeout('clearInterval(flash)', delay);
  49. setTimeout('cursp.style.visibility="visible"', delay);
  50. setTimeout('ticker()', delay);
  51. item=++item%news.length;
  52. }
  53. function linkit(q) {
  54. var a,p,e,l;
  55. p=news[q].indexOf("www");
  56. e=news[q].indexOf(" ", p);
  57. if (e==-1) e=news[q].length;
  58. l=news[q].substring(p, e);
  59. while (newsp.childNodes.length) newsp.removeChild(newsp.childNodes[0]);
  60. newsp.appendChild(document.createTextNode(news[q].substring(0, p)));
  61. a=document.createElement("a");
  62. a.href="http://"+l;
  63. a.appendChild(document.createTextNode(l));
  64. newsp.appendChild(a);
  65. newsp.appendChild(document.createTextNode(news[q].substring(e)));
  66. }
  67. // ]]>
  68. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement