How to tell if this Timeout is working?

Discussion in 'JavaScript' started by Jen-, Dec 2, 2006.

  1. #1
    Hello, I have a div on a timer below, but I don't know how to test if it is working. It is updating every 10 seconds, but since the text is the same, "test" nothing appears to be happening when it probably is. How can I add something to this so I can see some action every 10 seconds. I need to keep the div as the thing that is updating every 10. Thank you very much~~

    <script type="text/javascript">
    function change()
    {
    content = document.getElementById("content");
    setTimeout('change()',10000);
    }
    </script>
    </head>
    <body>
    <div class="main" style="border: 5px solid rgb(0, 0, 0);">
    <div class="body">
    <div id="content">test</div>
    </div>
    </div>
    </body>
    </html>
     
    Jen-, Dec 2, 2006 IP
  2. TechEvangelist

    TechEvangelist Guest

    Messages:
    919
    Likes Received:
    140
    Best Answers:
    0
    Trophy Points:
    133
    #2
    Errr... it's not doing anything right now. You have to call the change function before it does anything. I'm not sure what you are trying to do here.

    When I'm trying to see if a function is working properly, I add an alert box with the JavaScript variables I'm monitoring. Add it on the line just after your setTimeout method. When you call the function, you should see the alert box pop up 10 seconds later.
     
    TechEvangelist, Dec 2, 2006 IP
  3. Jen-

    Jen- Peon

    Messages:
    151
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    The alert worked thanks.
     
    Jen-, Dec 2, 2006 IP