Results 1 to 2 of 2

Thread: I have a java script that continously flashes the BG...

  1. #1

    Thread Starter
    Addicted Member Daniel_Christie's Avatar
    Join Date
    Jan 2000
    Location
    USA
    Posts
    245
    I have a java script that continously flashes the Back Ground. I would like to know how you would go about re-writing it so it will stop flashing the back ground after a short period of time, say, 5 seconds or so?

    Here is the code:

    Code:
    <SCRIPT LANGUAGE="JavaScript">
    var pos = 10;
    function initArray() {
    this.length = initArray.arguments.length;
    for (var i = 0; i < this.length; i++) {
    this[i] = initArray.arguments[i];
       }
    }
    var col=new initArray("4b","5b","8b","8b");
    function stop() {
    document.bgColor = '#FFFFFF';
    clearTimeout(loopID);
    }
    function start() {
    col[1]="red"
    col[2]="yellowgreen"
    col[3]="yellow"
    col[4]="whitesmoke"
    col[5]="white"
    col[6]="wheat"
    col[7]="violet"
    col[8]="turquoise"
    col[9]="tomato"
    col[10]="thistle"
    pos++;
    if (pos<0||pos>10) {
    pos = 0;
    }
    document.bgColor = col[pos];
    loopID = setTimeout("start()",1000);
    }
    
    </SCRIPT>
    Any takers?
    I appreciate all of your time and effort,
    Daniel Christie
    VB 5 and 6 Enterprise Editions,
    Html, Java scipt, Vb script,
    & etc...
    http://www.qwcd.com

  2. #2
    Guest
    Try this :


    <SCRIPT LANGUAGE="JavaScript">
    var pos = 1;
    function initArray() {
    this.length = initArray.arguments.length;
    for (var i = 0; i < this.length; i++) {
    this[i] = initArray.arguments[i];
    }
    }
    var col=new initArray("4b","5b","8b","8b");
    function stop() {
    document.bgColor = '#FFFFFF';
    clearTimeout(loopID);
    }
    function start() {
    col[1]="red"
    col[2]="yellowgreen"
    col[3]="yellow"
    col[4]="whitesmoke"
    col[5]="white"
    col[6]="wheat"
    col[7]="violet"
    col[8]="turquoise"
    col[9]="tomato"
    col[10]="thistle"
    pos++;
    if ( pos==10) {

    stop();
    }
    document.bgColor = col[pos];
    loopID = setTimeout("start()",1000);

    }

    </SCRIPT>


    </HEAD>
    <BODY onload="start()">

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