Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2012
    Posts
    10
    Thanks
    4
    Thanked 0 Times in 0 Posts

    HELP-How to change font in JavaScript

    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:

    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>

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,928
    Thanks
    6
    Thanked 1,041 Times in 1,014 Posts
    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).

  • #3
    New Coder
    Join Date
    Jan 2012
    Posts
    10
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    3,020
    Thanks
    56
    Thanked 566 Times in 563 Posts
    Code:
    <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>

  • #5
    New Coder
    Join Date
    Jan 2012
    Posts
    10
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Smile

    thank you thank you thank you!!!


  •  

    LinkBacks (?)


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •