Showing posts with label random quotes widget blogger. Show all posts
Showing posts with label random quotes widget blogger. Show all posts

Thursday, February 2, 2012


I wanted to show random quotes on my blog’s sidebar but unfortunately I could not find a single widget for this purpose. Then I found a few Java Scripts on Random Texts and Random Quotes. All of them were not good for the job. Then finally I got a code from www.JavaScriptBank.com which I was able to adapt for Blogger. Let's see how to install and customize it.

Installation

The installation is simple, just take a HTML/JavaScript gadget and copy and paste the following code on it:
<p id="textrotator">(Loading...)</p>

<script language="JavaScript">

function rotateEvery(sec)
{
var Quotation=new Array()

// QUOTATIONS
Quotation[0] = '&ldquo; First Quote.&rdquo; - <a href="#">Author</a>';
Quotation[1] = '&ldquo; Second Quote.&rdquo; - <a href="#">Author</a>';

var which = Math.round(Math.random()*(Quotation.length - 1));
document.getElementById('textrotator').innerHTML = Quotation[which];
   
setTimeout('rotateEvery('+sec+')', sec*1000);
}
rotateEvery(2);

</script>
<span style='font-size:75%;float:right;'>Powered by <a href='http://inkoflife.blogspot.com/'>Ink of Life</a></span>
Save it and you are done. In case, you are new on Blogger and don’t know how to add a gadget then follow the undermentioned procedures:

1. Log into the blogger Dashboard

2. Click on the Design tab


3. Click on Add a Gadget in your desired location (on click a new window will appear)

4. From the new window Select HTML/JavaScript


5. Give a Title of the Gadget if you wish, such as: Random Quotes

6. Paste Random Quotes Widget code under Content section

7. Click Save


Customization

Changing Quotes
Write your quote in the place marked in red and the author's name in the place marked in green:

Number of Quotes
You can add as many quotes as you wish. By default I have provided provision for two quotes. You can include more quotes in the following way:

Adding Hyperlink
You can add a link to your individual quotes with related pages. To do so just replace the # with the desired link:
 
That means after addition of the link your code will look like something like this:

Changing Duration
By default the duration is set to 2 seconds. For example:


You can increase or decrease the timing if you wish. For Example in the following example I have set the duration to 12 seconds:

Some Issues

By chance your quote contains any apostrophe then replace it with this code:



Follow Us

Blog Archive

Popular Posts