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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delay to catch accidental mouseover

Status
Not open for further replies.

Cassien

Programmer
Sep 17, 2002
94
0
0
I've written a JS based menu using mouseover to display dynamic content on a page. The problem comes when a user moves their mouse from the location to another part of the page, if they brush over a different active spot the dynamic content will change. Is there a way of implementing a delay which would allow for brush overs, say of half a second, to avoid changing the dynamic content by accident?

 

Yes - you can instigate a .5 second timer like this:

Code:
var timerHandle = setTimeout('alert(\'Hello World!\'', 500);

And you can clear the timer like this:

Code:
clearTimeout(timerHandle);

Hope this helps,
Dan
 
Hi Dan,

Thanks for your help.

I'm having some trouble implementing it, probably due to my java inexperience. The code I am using is displayed below, effectively. So on mouseover the menu is called, I would like to use your code to call it assuming the mouse stays within the menu for more than half a second, could you please explain how to do this?

<Code>
OnMouseOver=DisplayMenu("ThisMenu")

function DisplayMenu(menuID) {

<Code to Display the Menu>

return;
}
</Code>

Thanks greatly for your help, I'll continue to fiddle!

Cass
 
Thanks Dan,

After some faffing and a few changes I got the code to work

Many thanks for your help,

Cass
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top