Posted By

apphp-snippets on 05/26/17


Tagged

javascript random quotes


Versions (?)

Display Random Quotes with JavaScript


 / Published in: JavaScript
 

URL: http://www.apphp.com/index.php?snippet=javascript-display-random-quotes

This snippet code allows you to prevent the viewer from being able to right-click on your page. This can discourage the average user from borrow images or code from your site.

  1. <script type="text/javascript">
  2. writeRandomQuote = function () {
  3. var quotes = new Array();
  4. quotes[0] = "Action is the real measure of your intelligence.";
  5. quotes[1] = "The baseball has a great advantage over cricket of being sooner ended.";
  6. quotes[2] = "Every goal, every action, every thought, every feeling one experiences, whether it be consciously or unconsciously known, is an attempt to increase one’s level of peace of mind.";
  7. quotes[3] = "A good head and a good heart are always a formidable combination.";
  8. var rand = Math.floor(Math.random()*quotes.length);
  9. document.write(quotes[rand]);
  10. }
  11. writeRandomQuote();
  12. </script>
  13.  
  14. <script type="text/javascript">writeRandomQuote();</script>

Report this snippet  

You need to login to post a comment.