Note: This is targeted to users of
iBlog, but should work easily with any site.
Everytime I find a interesting quote I’ve wanted to rotate them through my site. I think there are some free services out there that will do them with a simple javascript but I hate having to have stuff hosted on other sites; it slows mine down. I found this site with some embedded javascript code that does basicly what I want except I dont’ want it embedded. So I modified it to be a file that I referece from within the templates in iBlog. It also has the advantage that when I want to update the quotes I only have to update one file, rather than every template file and republish every page of the stie.
The code looks like this:
/*
This Script was created by Daniel Standley
Please feel free to use it but make sure you give me credit
My Email is gandalf_au@kooee.com.au
and my website is standleydj.tripod.com
*/
// The quotes that appear on the page.
quotes = new Array("<i>"I think we ought to raise the age at which juveniles can have a gun."</i> - George W. Bush","<i>"They misunderestimated me."</i> - George W. Bush","<i>"I have no special talents I am only passionately curious"</i> - Albert Einstein","<i>"The report of my death was an exaggeration"</i> - Mark Twain","<i>"One began to hear it said that World War I was the chemists' war, World War II was the physicists' war, World War III (may it never come) will be the mathematicians' war"</i> - Davis, Philip J. and Hersh, Reuben", " ""They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety"</i> - Benjamin Franklin")
//Alter nothing below the script wont work if you do.
qte = quotes.length
function chooseQuote(){
randomNum = Math.floor
((Math.random() * qte))
document.write(quotes[randomNum])
}
The actual quotes are contained in the part that says quotes = new Array( ). You will see some comma seperated values in quotes. You can add or change the ones that are there
To use it take that text and paste it into a text editor. Save it as a plain text file called quotegenerator.js and put it where ever you publish your blog to. You will need to put a line in the template files you wish to use it in.
Put this inbetween the head tags:
<script type="text/javascript" src="<$>quotegenerator.js" language="JavaScript"></script>
To use the quote generator put this bit of code in your site:
<script type="text/javascript">chooseQuote();</script>
I put this in my blog description portion of iblog so it looks like this:
Since iBlog doesn’t use a javascript function for the description it works perfectly.