The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Try making one function which displays the text "Feel free to look around" and one to display "Thanks", then call them using the window.setTimeout method after 1000ms (=1 second) and 2000ms (=2 seconds).

Also remember that someone might not look at your page for the full two seconds!

Try making one function which displays the text "Feel free to look around" and one to display "Thanks", then call them using the window.setTimeout method after 1000ms (=1 second) and 2000ms (=2 seconds).

Also remember that someone might not look at your page for the full two seconds!

Douglas

Thanks, what code would I use for this?

I tried the setTimeout with document.write but it made it a blank page with the written text.

Hmm, Javascript is a Functional programming language, that means that functions are important to the language. We can rewrite the code above to not use the global array or the global counter. (Globals are generally a bad thing, as you can only have them once on a page. It makes it more likely that two scripts will interfere with each other and break.)

Notice that now we don't need the global array, the global counter, storage for the helloInterval, we don't need to call clearInterval, there is no if statment, we only call document.getElementById once, and we have full control over when each message is shown and what message to add (Functional programming is nice ).