How do I make this script work with Mozilla browsers?

Discussion in 'Javascript' started by Caledonia_558, Nov 5, 2004.

  1. Hi everyone,
    I'm having trouble with a bit of code to make a paragraph of text
    change colour every second to a new, random colour:
    Here's the script's function:

    <script type="text/javascript">
    function change()
    {
    re="rgb("+Math.round(Math.random()*256)+","+
    Math.round(Math.random()*256)+","+Math.round(Math.random()*256)+")"
    text.style.color=re;
    }
    setInterval(change,1000);
    </script>

    Then you create the text you want to change colour in a paragraph with
    id "text":

    <p id="text"> Here is where you type your text. </p>

    This works beautifully in IE and Opera, but does absolutely nothing in
    Mozilla-based browsers. Can I do anything to this script to make it
    work in Mozilla browsers?
    Thanks!
     
    Caledonia_558, Nov 5, 2004
    #1
    1. Advertising

  2. Caledonia_558 wrote:

    > text.style.color=re;
    > <p id="text"> Here is where you type your text. </p>


    http://jibbering.com/faq/#FAQ4_41

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
     
    David Dorward, Nov 5, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jonel Rienton

    ASP.Net and Mozilla browsers

    Jonel Rienton, Nov 28, 2003, in forum: ASP .Net
    Replies:
    5
    Views:
    2,287
    stefano mostarda
    Nov 28, 2003
  2. Frank Rizzo
    Replies:
    6
    Views:
    416
    Frank Rizzo
    Jan 15, 2004
  3. Chad Lupkes
    Replies:
    3
    Views:
    595
    Chad Lupkes
    Aug 16, 2003
  4. Henri
    Replies:
    9
    Views:
    1,906
    Toby Inkster
    Feb 22, 2005
  5. El Kabong

    Browsers, browsers! Quo vadis?

    El Kabong, May 11, 2007, in forum: HTML
    Replies:
    23
    Views:
    948
    dorayme
    May 13, 2007
Loading...

Share This Page