View Full Version : Need help with a javascript
Prime
07-29-2003, 06:20 AM
"Random motivational quotes"
Okay, is there anyway I can control the font/size of the quotes?
Thanks
fredmv
07-29-2003, 07:32 AM
You would need to provide us with the code you're using for us to give you a more accurate answer...
But I'm sure the script basically consists of printing a random array element.
So all you would need to do is use CSS to alter the font style of the randomly selected element from the array. I just wrote this -- Just change the fColor, fSize, fFamily variables to change how the quote appears.
<script type = "text/javascript">
//--Config section--
//
var fColor = "#0000ff"; //color (blue)
var fSize = 12; //size (12pt)
var fFamily = "Verdana"; //font (Verdana)
//The array of quotes.
//
var quotes = new Array("Quote 1", "Quote 2", "Quote 3", "Quote 4", "Quote 5");
//Print out a random element from it.
//Format the text using CSS with the
//variables above.
//
document.writeln("<span style = 'font-family:" + fFamily + "; font-size:" + fSize + "pt; color:" + fColor + ";'>" + quotes[Math.floor(Math.random()*quotes.length)] + "<\/span>");
</script>
Hope that helps you out, good luck.
Prime
07-29-2003, 08:29 PM
My fault. I thought because this was a messageboard of a site, that if I got a script off of the site, I could just put the name here. Here is the link to the script:
http://javascriptkit.com/script/script2/motivatequotes.shtml
But I do see the var things so I will try experiementing with them.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.