Posted By

powerserve on 09/10/09


Tagged

refresh text change


Versions (?)

Text Change on Refresh


 / Published in: JavaScript
 

URL: http://www.brendadansby.com/

  1. Add this in your <head>
  2. <script language="javascript" type="text/javascript" src="/js/refresh/refresh.js"></script>
  3.  
  4. Add this in your <body>
  5. <script language="javascript" type="text/javascript">
  6. showText();//Shows Random Text on refresh
  7. </script>
  8.  
  9.  
  10. // JavaScript Document
  11.  
  12. // Set up the text files to be used.
  13. var theText = new Array() // do not change this
  14.  
  15.  
  16. theText[0] = 'Test 1';
  17. theText[1] = '"Test 2"';
  18. theText[2] = '<a href="#" title="test 3">Test 3</a>';
  19.  
  20. // do not edit anything below this line
  21.  
  22. var j = 0
  23. var p = theText.length;
  24. var preBuffer = new Array()
  25. for (i = 0; i < p; i++){
  26. preBuffer[i] = new Array()
  27. preBuffer[i].src = theText[i]
  28. }
  29. var whichText = Math.round(Math.random()*(p-1));
  30. function showText(){
  31. //This a wrapper for the text array it can be changed if need
  32. document.write('<p class="thetext">'+theText[whichText]+'</p>');
  33. }

Report this snippet  

You need to login to post a comment.