/    Sign up×
Community /Pin to ProfileBookmark

Collapsing menu by time delay.

This code here works but I’d like to add a couple features.

First and for most, this will collapse whether the user is using
my menu or not, I’d like to set up a onHover event to delay or
reset the countdown. Another one I would like to issue is that
since this function ends at 15*1000+1 (interval is 5*1000 btw),
if the user reopens the menu, the countdown is already finished,
I would like to reset it for another 15sec. Anyone want to help
me out? ?

[code]
var myInterval = window.setInterval(function (a,b) {
extendContract();
},15*1000);

window.setTimeout(function (a,b) {
clearInterval(myInterval);
},15*1000+1);
[/code]

with a bodyload of “”extendContract();

Thanks Guys!

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@ehimeauthorJul 01.2009 — So by using this I got it to close itself after 15sec.

I'm still trying to figure out how to pause or reset

it while the user is hovering. I tried using:

document.getElementById("sideBar") to no effect,

throws error about invalid ID (it isn't btw)

Fixed the interval with code

<i>
</i> &lt;script language="javascript" type="text/javascript"&gt;
var myInterval = window.setInterval(function (a,b) {
extendContract();
},15*1000);

<i> </i> window.setTimeout(function (a,b) {
<i> </i> clearInterval(myInterval);
<i> </i> },15*1000+1);
<i> </i> &lt;/script&gt;

<i> </i> &lt;/head&gt;

<i> </i>&lt;body onload="extendContract();"&gt;


and

<i>
</i>$(function() {
$("#sideBarTab").click(function() {
extendContract();
var myInterval = window.setInterval(function (a,b) {
extendContract();
},15*1000);

<i> </i> window.setTimeout(function (a,b) {
<i> </i> clearInterval(myInterval);
<i> </i> },15*1000+1);
<i> </i> return false
<i> </i>},
<i> </i>function() {})
});
×

Success!

Help @ehime spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...