How to code a random quote generator in FrontPage?

J

JKH

I'm building a website (my first) using FrontPage 2003. I want to insert a
random quote (from a file of quotes) on the website. How do I do this?
 
J

JBL

You can insert this script in between your body tags to wherever you want it
to display. Just change the part in paranthesis to whatever quotes you want
to use. It is set for ten quotes, but you can add as many as you like.


<SCRIPT language="JavaScript">
<!--
function get_random(maxNum)
{
if (Math.random && Math.round)
{
var ranNum= Math.round(Math.random()*(maxNum-1));
ranNum+=1;
return ranNum;
}
else
{
today= new Date();
hours= today.getHours();
mins= today.getMinutes();
secn= today.getSeconds();
if (hours==19)
hours=18;
var ranNum= (((hours+1)*(mins+1)*secn)%maxNum)+1;
return ranNum;
}
}

function getaQuote()
{
var maxQuotes=10;
var whichQuote=get_random(maxQuotes);
whichQuote--;

var quote=new Array(maxQuotes)
quote[0]="Quote #1";
quote[1]="Quote #2";
quote[2]="Quote #3";
quote[3]="Quote #4";
quote[4]="Quote #5";
quote[5]="Quote #6";
quote[6]="Quote #7";
quote[7]="Quote #8";
quote[8]="Quote #9";
quote[9]="Quote #10";

document.write(quote[whichQuote]);

}

getaQuote();

//-->
</SCRIPT>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top