Looking for startup ideas.? Visit Reinventor.ca

Random Quotes on Refresh Widget For Blogger / WebSites

Preview
Here is an interesting Blogger Widget which is meant to show random quotes on refreshing page. I wanted to show random quotes on my blog’s author box but unfortunately I could not find a single widget for this purpose which was quick and easy and do not effect page load. Then I found a few Java Scripts on Random Texts and Random Quotes merged them together to create a new and most convenient widget.
 

Here are Installation Instructions For Blogger users, however other platform users can simply copy the code for their utilize. 

For Bloggers  
 If you want to place it to sidebar. Otherwise simple copy the code and paste it to the
template editor between Body Tags.
  • Open the Layout Editor
  • Click 'Add a Page Element' , 
  • and select 'Configure HTML/JavaScript'. 
  • Paste following code there ----->
<script language="JavaScript">
//store the quotations in arrays
quotes = new Array(6);
quotes[0] = "So many cats, so few recipes.";
quotes[1] = "Use the best: Linux for servers, Mac for graphics, Windows for Solitaire.";
quotes[2] = "That's not a haircut. That's a cry for help.";
quotes[3] = "The last thing I want to do is hurt you. But it's still on the list.";
quotes[4] = "Some days it's just not worth gnawing through the leather straps.";
quotes[5] = "Doing for blogging what Ghengis Khan did for social work.";
//calculate a random index
index = Math.floor(Math.random() * quotes.length);
//display the quotation
document.write("\n");
document.write(quotes[index]);
//done
</script>
  • And CLick on save button.
I've had some requests on how to put in more quotes, so here are more explicit instructions on doing just that. This is like the 'formula'. I know, Algebra is scary, but this is only a tiny formula with hardly any numbers and a couple of 'x's!

quotes = new Array(X + 1);

and you add another line for each new quote:

quotes[X] = "Your new quote";

Let's say you want 10 quotes. In 'Array you will put 11 (which is the x +1 or 10 + 1 from the formula). That will make your code look like this:

first part of code.....
quotes = new Array(11);
quotes[0] = "So many cats, so few recipes.";
quotes[1] = "Use the best: Linux for servers, Mac for graphics, Windows for Solitaire.";
.....blah, more quotes, blah....
quotes[10] = "Doing for blogging what Ghengis Khan did for social work.";
.....last part of code

If that doesn't clear it up, let me know!

    Share this:

    ABOUT THE AUTHOR

    Hello We are OddThemes, Our name came from the fact that we are UNIQUE. We specialize in designing premium looking fully customizable highly responsive blogger templates. We at OddThemes do carry a philosophy that: Nothing Is Impossible

    1 comments: