...

View Full Version : HELP-How to change font in JavaScript



monkeydo98
01-05-2012, 12:45 AM
I have a javascript that randomly displays a different quote on my website. I have the quote programmed in, and they show up, but the text is tiny. I need help making the text bigger. I am a beginner at this, so i would appreciate help. This is the code:


<script language='JavaScript'>
function random_content(){
var mycontent=new Array()
mycontent[1]='Repent! The end is coming! Were out of chips!'
mycontent[2]='I WANT, TO EAT, A DINOSAUR.'
mycontent[3]='Last night I lay in bed looking up at the stars in the sky and I thought to myself, where the heck is the ceiling.'
mycontent[4]='IT\'S A TRAP!'
mycontent[5]='tardo power,activate!'
mycontent[6]='LMS if ur gay'
mycontent[7]='1,2,...5!'
mycontent[8]='Box O Digletts'
mycontent[9]='Justice is best served cold, with a side of ranch dressing'
mycontent[10]='umm...I got nothing...awkward'
mycontent[11]='Once you visit you can never leave'
mycontent[12]='50% CaCow'
mycontent[13]='almost racist free!'
mycontent[14]='The last thing I want to do is hurt you. But it\'s still on the list'
mycontent[15]='BOOM! Left turn!'
mycontent[16]='Redrum'
mycontent[17]='If 4 out of 5 people SUFFER from diarrhea... does that mean that one enjoys it?'
mycontent[18]='Never, under any circumstances, take a sleeping pill and a laxative on the same night'
mycontent[19]='the beginning of the end'
mycontent[20]='Flaming fireballs Batman!'
mycontent[21]='gotta catch em\' all'
mycontent[22]='for the african children!'
mycontent[23]='One sexy thang'
mycontent[24]='It\'s Tardolicious!'
mycontent[25]='That\'s no moon!'
mycontent[26]='Caboose is god?'
mycontent[27]='MLIT'
var ry=Math.floor(Math.random()*mycontent.length)
if (ry==0)
ry=1
document.write(mycontent[ry])
}
random_content()
//-->
</script>

VIPStephan
01-05-2012, 01:26 AM
To style your content you’d use CSS, not JavaScript. Wrap an element (e. g. a div) around that script block, assign an ID to it (e. g. “quote”) and use the ID as CSS selector to style it (i. e. change the font size).

monkeydo98
01-05-2012, 02:55 AM
thank you for the answer, but i am still confused. The content is javascript, and im trying to figure out how to make my javascript content bigger in font. Also, i am very, very, new and have no idea about any thing you said. Im sorry, but thank you for answering.

xelawho
01-05-2012, 04:16 AM
<html>
<head>
<style type="text/css">
#waytoobig {font-size:500px;}
</style>
</head>
<body>
<div id="waytoobig"></div>
<script type="text/javascript">
function random_content(){
var mycontent=new Array()
mycontent[0]='MLIT'
mycontent[1]='Repent! The end is coming! Were out of chips!'
mycontent[2]='I WANT, TO EAT, A DINOSAUR.'
mycontent[3]='Last night I lay in bed looking up at the stars in the sky and I thought to myself, where the heck is the ceiling.'
mycontent[4]='IT\'S A TRAP!'
mycontent[5]='tardo power,activate!'
mycontent[6]='LMS if ur gay'
mycontent[7]='1,2,...5!'
mycontent[8]='Box O Digletts'
mycontent[9]='Justice is best served cold, with a side of ranch dressing'
mycontent[10]='umm...I got nothing...awkward'
mycontent[11]='Once you visit you can never leave'
mycontent[12]='50% CaCow'
mycontent[13]='almost racist free!'
mycontent[14]='The last thing I want to do is hurt you. But it\'s still on the list'
mycontent[15]='BOOM! Left turn!'
mycontent[16]='Redrum'
mycontent[17]='If 4 out of 5 people SUFFER from diarrhea... does that mean that one enjoys it?'
mycontent[18]='Never, under any circumstances, take a sleeping pill and a laxative on the same night'
mycontent[19]='the beginning of the end'
mycontent[20]='Flaming fireballs Batman!'
mycontent[21]='gotta catch em\' all'
mycontent[22]='for the african children!'
mycontent[23]='One sexy thang'
mycontent[24]='It\'s Tardolicious!'
mycontent[25]='That\'s no moon!'
mycontent[26]='Caboose is god?'

var ry=Math.floor(Math.random()*mycontent.length)
document.getElementById("waytoobig").innerHTML=mycontent[ry];
}
random_content()
//-->
</script>
</body>
</html>

monkeydo98
01-05-2012, 11:36 PM
thank you thank you thank you!!!:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum