Results 1 to 7 of 7

Thread: Changing Bgcolor

  1. #1

    Thread Starter
    Fanatic Member cid's Avatar
    Join Date
    Nov 2002
    Location
    Fort Worth, Texas
    Posts
    854

    Arrow Changing Bgcolor

    I want a timer to change the bgcolor every second. So here is what I have so far:

    <html>
    <head>
    <Body bgcolor = "Black">
    <script type="text/javascript">
    function start() {
    var timeout = setTimeout("Timeout();",2000);
    }

    function Timeout() {
    <Body BGcolor = "Red">
    var timeout = setTimeout("Color2();",1000);
    }

    function Color2() {
    <Body BGcolor = "Green">
    var timeout = setTimeout("Color3();",1000);
    }

    function Color3() {
    <Body Bgcolor = "Lime">
    }
    </script>

    </head>
    <body onLoad="start()">
    </body>
    </html>

    www.google.com - Pay Tribute.

    Always Listening To: Thrice

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Changing Bgcolor

    <script type="text/javascript">
    function start() {
    var timeout = setTimeout("Timeout();",2000);
    }

    function Timeout() {
    document.bgcolor = 'red';
    var timeout = setTimeout("Color2();",1000);
    }

    function Color2() {
    document.bgcolor='green';
    var timeout = setTimeout("Color3();",1000);
    }

    function Color3() {
    document.bgcolor='lime';
    }
    </script>

  3. #3

    Thread Starter
    Fanatic Member cid's Avatar
    Join Date
    Nov 2002
    Location
    Fort Worth, Texas
    Posts
    854
    I cant figure out was is wrong with this code. I put the code in notepad. And it doesnt do anything:

    Code:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    <HTML>
    <Body>
    <script type="text/javascript">
    function start() {
    var timeout = setTimeout("Timeout();",2000);
    }

    function Timeout() {
    document.bgcolor = "Red";
    var timeout = setTimeout("Color2();",1000);
    }

    function Color2() {
    document.bgcolor="green";
    var timeout = setTimeout("Color3();",1000);
    }

    function Color3() {
    document.bgcolor="lime";
    }
    </Body>
    </script>
    </HTML>

    www.google.com - Pay Tribute.

    Always Listening To: Thrice

  4. #4
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099
    there isnt anything calling the first function called start.


    Code:
    <HTML>
    <Body>
    <script type="text/javascript">
    function start() {
    var timeout = setTimeout("Timeout();",2000);
    }
    
    function Timeout() {
    document.bgcolor = "Red"; 
    var timeout = setTimeout("Color2();",1000);
    }
    
    function Color2() {
    document.bgcolor="green";
    var timeout = setTimeout("Color3();",1000);
    }
    
    function Color3() {
    document.bgcolor="lime";
    }
    start(); /*----that should start it off*/
    </Body>
    </script>
    </HTML>
    but your codfe will only change the colour threes times, if u want to loop it again you need to add stuff in to your functio Color3

  5. #5

    Thread Starter
    Fanatic Member cid's Avatar
    Join Date
    Nov 2002
    Location
    Fort Worth, Texas
    Posts
    854
    It just sat there and didnt do anything. I have no clue what is wrong.

    www.google.com - Pay Tribute.

    Always Listening To: Thrice

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    You're trying to run this from notepad????
    Tell me I read that wrong.

  7. #7

    Thread Starter
    Fanatic Member cid's Avatar
    Join Date
    Nov 2002
    Location
    Fort Worth, Texas
    Posts
    854
    I type the code into notepad. Then change the file extension to .html Then open it as a web document. I may be an idiot when it comes to HTML but im not that big of one.

    www.google.com - Pay Tribute.

    Always Listening To: Thrice

Posting Permissions

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



Click Here to Expand Forum to Full Width