Click to See Complete Forum and Search --> : How do I manipulate the font of my random quote?


Ambrosia
10-10-2003, 12:44 AM
This is the script that I'm using:

<CENTER>
<SCRIPT LANGUAGE="JavaScript">
var howMany = 5
var quote = new Array(howMany+1)
quote[0]="Force, and fraud, are in war the two cardinal virtues."
quote[1]="War is the great scavenger of thought."
quote[2]="War is the supreme drama of a completely mechanized society."
quote[3]="The quickest way of ending a war is to lose it."
quote[4]="Anyone who has ever looked into the glazed eyes of a soldier dying on the battlefield will think hard before starting a war."
quote[5]="There is nothing so subject to the inconstancy of fortune as war."function rndnumber(){
var randscript = -1
while (randscript < 0 || randscript > howMany || isNaN(randscript)){
randscript = parseInt(Math.random()*(howMany+1))
}
return randscript
}
quo = rndnumber()
quox = quote[quo]
document.write(quox)
</SCRIPT>
</CENTER>

+++++
This is the type of word art i want to place it with:

<span style="width: 100%; font-family: Papyrus; color: white; Filter: Glow (Add = 1, Direction = 225, Strength = 10); font-weight:700">
<font size="4"> "quote message should go here" </font></span>

Can this be done? Thanks in ADVanCE!

chestertb
10-10-2003, 02:28 AM
Hi,

Have you tried innerHTML?

The create a function something like this...

function quote()
{
//*create your random quote into var quox as you have
done, placing that code here. Then create a single line string like this...*//

var pre = "<span style=\"width: 100%\; font-family: Papyrus\; color: white\; Filter: Glow (Add = 1, Direction = 225, Strength = 10)\; font-weight:700\"><font size=\"4\">";

var pst = "</font></span>";

msgstring = pre + quox + pst;

//*you'll notice that the ", ' and ; characters have all been escaped by preceeding them with the backslash.*//

//*You then create a function to insert the random quote... and this is tricky, because innerHTML is handled differently by MSIE and two versions of Netscape.*//


if(document.layers)
{
//thisbrowser="NN4";
putit = document.layers["quotehere"];
putit.document.open();
putit.document.write(msgstring);
putit.document.close();
}

if(document.all)
{
//thisbrowser="ie"
quotehere.innerHTML = msgstring;
}

if(!document.all && document.getElementById)
{
//thisbrowser="NN6";
var putit = document.getElementById("quotehere");
putit.innerHTML = msgstring;
}

}

You can either put that function into the head of your document, or in an external script.

In the body of your HTML, at the place where you want the quote to appear, create a div called "quotehere"...

Something like

<div id="quotehere">
</div>

To actually display your random quote, just call the function quote(). I usually put the javascript call last in the body of the page like this...

<script language="Javascript">
<!--
quote()
//-->
</script>

Hope this helps.

IB.