473,386 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

make a div disappear after a few seconds

Hi all,

I've created a DIV with important notes for my site. I've a Close button on
it, but would like to have a timer that automatically close the div is it
hasn't been closed after a few seconds (let's say 5 seconds). Thanks for
your help.

How to do so ?

Oct 13 '06 #1
5 37911
Bob Bedford wrote:
Hi all,

I've created a DIV with important notes for my site. I've a Close button
on it, but would like to have a timer that automatically close the div is
it hasn't been closed after a few seconds (let's say 5 seconds). Thanks
for your help.

How to do so ?
Hi

Use setTimeout();

eg:
<div id="helpdiv" style="display:block">
helpstuff here
</div>

<script type="text/javascript">
// close the div in 5 secs
window.setTimeout("closeHelpDiv();", 5000);

function closeHelpDiv(){
document.getElementById("helpdiv").style.display=" none";
}
</script>

Regards,
Erwin Moller
Oct 13 '06 #2
Erwin Moller wrote:
// close the div in 5 secs
window.setTimeout("closeHelpDiv();", 5000);

function closeHelpDiv(){
document.getElementById("helpdiv").style.display=" none";
}
Slightly cleaner, use a function reference rather than a string to
eval():

function closeHelpDiv(){
document.getElementById("helpdiv").style.display=" none";
}

// close the div in 5 secs
window.setTimeout( closeHelpDiv, 5000 );

Oct 13 '06 #3

"Phrogz" <ga***@refinery.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
// close the div in 5 secs
window.setTimeout( closeHelpDiv, 5000 );
From Javascript 1.3 spec:

"The expression must be quoted; otherwise, setTimeout calls it immediately."

nf
Oct 13 '06 #4
nutso fasst wrote:
"Phrogz" <ga***@refinery.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
// close the div in 5 secs
window.setTimeout( closeHelpDiv, 5000 );

From Javascript 1.3 spec:

"The expression must be quoted; otherwise, setTimeout calls it immediately."
Notice that I did not put parentheses on the end of that function name.
Thus, "calling it immediately" resolves the variable reference to the
function; setTimeout invokes that function object when required.

Oct 13 '06 #5

"Phrogz" <ga***@refinery.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Notice that I did not put parentheses on the end of that function name.
Thus, "calling it immediately" resolves the variable reference to the
function; setTimeout invokes that function object when required.
Ah, so. Thanks for edification.

Oct 13 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: salamol | last post by:
I has a strange question. My company is using a old system with Win NT 4.0 Server + MS SQL 7.0. The system is busy and handle a lot of SELECTs and INSERTs all the time. Sometimes, some...
6
by: Nicolae Fieraru | last post by:
Hi All, I recently discovered that my session cookies on the web host disappear within 30 seconds. I created some very simple asp scripts (it took me a while until I discovered why my shopping...
2
by: mja674s | last post by:
I'm making a date picker. It shows up fine. The problem is that I want it to disappear if I click outside the calendar itself. However, if I click *on* the calendar itself, it should not...
40
by: findmadhav | last post by:
I need a program in C (something like a TSR) which will automatically press the function key F6, say about every 5 seconds. Can anyone provide me with an exe of such a program? Thanks in advance.
0
by: Marcin Szarek | last post by:
Hi! For a few months we suffer mysterious problem with Oracle 10g RAC (more details on server configuration at the bottom). At regular basis (every 5 minutes) nodes of our cluster "freeze" -...
4
by: Claus Tondering | last post by:
I am trying to make a Tkinter main window appear and disappear, but I have problems with that. Here is a small code sample: class MyDialog(Frame): def __init__(self): Frame.__init__(self,...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
3
by: drakkofox | last post by:
Hi there, i need to subtract 36000 seconds, or a day, to get the yesterday's date, but with consistence check. for example, if i input the date 01/03/2007(dd/mm/yyyy) on the program, it should...
5
by: Susan Bricker | last post by:
I have a command button that I'd like to make "disappear" after being clicked and after the OnClick function has executed. I have tried changing the 'visible' attribute to false while within the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.