Show a message for num of seconds?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

Show a message for num of seconds?

Post by Sindarin »

How can I show a message to the user the way Wordpress does it? It doesn't have to fade out or anything funky, I just need it to hide after 10 seconds.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Show a message for num of seconds?

Post by VladSun »

I don't know how Wordpress does it, but I think you are looking for setTimeout()
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

Re: Show a message for num of seconds?

Post by Sindarin »

Code: Select all

function showMsg()
{
var t=setTimeout("document.write('test')",2000);
hideMsg();
}
function hideMsg()
{
var t=setTimeout("document.write(' ')",3000);
}
It seems I could do it that way, but still document.write removes any other code, does anyone know how to use document.write but also keep the current document code?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Show a message for num of seconds?

Post by VladSun »

You need a DIV which will display/hide the message and write to its contents by using its innerHTML attribute.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

Re: Show a message for num of seconds?

Post by Sindarin »

what? 8O *so much stuff to start with*
Post Reply