[thelist] timing, setTimeout and setInterval
Joseph A Borg
jacborg at mac.com
Wed Jun 12 16:18:01 CDT 2002
On Wednesday, June 12, 2002, at 06:19 PM, Tom Dell'Aringa wrote:
> Any ideas are greatly appreciated! Feel free to suggest alternatives to
> how I am doing this, I am
> open to anything that will suit the purpose.
My js is very scratchy... but I just created these functions for a site
in development.
I have some sub-menus encapsulated in absoluted <div>s. The items in the
menus are positioned with a table... onMouseOver the main menu links
calls these two events:
1 the related submenu shows up
2 sets a timer to hide the same submenu
if the submenu gets hidden before timeout, well, the function will
execute but changes the visibility value to what it already is... hidden!
the code (hope it works for you! any improvements would be appreciated...
regards
// ## Joe's scripts
var menuClear=5000; //global timer limit optionally used in html pages
var widgetTimer; //this widget thing will someday work with resetTimer
//if I figure out how to cancel the timeout when the
//pointer is on a table
function JBsetTimer(x,v,t) { //set delay to display called from html
var JBfn; JBfn = "JBshow('"+x+"', '"+v+"')";
widgetTimer = setTimeout(JBfn,t);
widgetTimer.item = x
widgetTimer.state = v;
}
// this function should reset the timer if there's a mouse over a
div/table
// the table is the problem... should I use onMouseOver or onMouseOut
function JBresetTimer(t) { //sort of works but doesn't do my bidding
exactly
if (widgetTimer.state == "visible") { window.clearTimeout(widgetTimer)
} else { JBtimer(widgetTimer.item,'hidden', t) }
}
function JBshow(x, v) { //show/hide function joe style
if (document.getElementById)
{document.getElementById(x).style.visibility=v } else
if (document.layers) {document.layers(x).visibility=v };
return true;
}
//---------------------------------------------------
Joseph A Borg
Salam, Triq Ta' Brija,
Siggiewi QRM 16
Malta
Tel: +356 21466218
More information about the thelist
mailing list