Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hide div content after Time delay of x

Status
Not open for further replies.

AKS44

Programmer
Feb 7, 2006
20
0
0
US
I am attempting to create a show/hide div that simply hides the content in the div after it's displayed for 30 seconds or soo. This needs to be cross platform (IE6-7, FireFox, NS, etc)

A good example can be seen at The Ad at the top will slide close after a period of time.

I have scowered the net for such code with out any luck, however I have found plenty on the jquery hide/show but this is more of a user interaction using a button. Not exactlly what I'm looking for.

Any help would be greatly appriceated.
 
If you look at the source code of that website you will find the answer: setInterval and setTimeout functions.

Cheers,
Dian
 
<div style="border:#000000 1px solid; width:200px; height:200px" id="some_id" onmouseout="hide_div(30);">div cont here</div>
<script>
var div_timer;
var div_timer=setTimeout("hide_div();",30000);
// 30000 == 30 000 Milliseconds = 30 Seconds
function hide_div(time_here){
if(time_here){
div_timer=setTimeout("hide_timer();",(time_here*1000));
}
else{
document.getElementById('some_id').style.visibility='hidden';
document.getElementById('some_id').style.display='none';
}
}
</script>
 
you can comment one of those :
this:
// var div_timer;
or this:
var div_timer=setTimeout("hide_div();",30000);

also u can remove the onmouseout event from the <div> tag
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top