/    Sign up×
Community /Pin to ProfileBookmark

Length of the mouseover-event?

hi ppl!
I just have a simple question:
How do I get out how long the mouseover-event is fired by an specific element? Let’s say for example I have a link or whatever and after 500miliseconds – the user being over it – a function is called.
I have no idea how to do that.
thx in advance
Chrisi

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@GollumJul 30.2003 — A common way is to call window.setTimeout in the mouseover event (saving the timeout id) to schedule a function call. If the onmouseout event happens before that, use the timeout to call clearTimeout
Copy linkTweet thisAlerts:
@CharlesJul 30.2003 — [font=monospace]<img src="http://forums.webdeveloper.com/avatar.php?userid=6428&dateline=1052734582" alt="[Gollum]" onmouseover="this.wait = setTimeout('alert('What are you looking at?')', 500)" onmouseout="clearTimeout(this.wait)">[/font]
×

Success!

Help @Chrisi 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...