JavaScript and client side scripting.
Moderator: General Moderators
kaily
Forum Newbie
Posts: 12 Joined: Fri Jul 05, 2002 12:17 pm
Post
by kaily » Sun Jul 28, 2002 10:49 am
I think javascript is a bit same as PHP, so I write the code:
Code: Select all
<html>
<head>
<script language=JavaScript1.2>
function Show(divid) {
divid.filters.revealTrans.apply();
divid.style.visibility = "visible";
divid.filters.revealTrans.play();
}
function Hide(divid) {
divid.filters.revealTrans.apply();
divid.style.visibility = "hidden";
divid.filters.revealTrans.play();
}
function menudown(target){
setTimeout("Hide(target)",5000);
}
</script>
</head>
<body>
<!-- HERE, the link "HELP" -->
<a href="help.php" onMouseOver="Hide(lastdiv); document.lastdiv=help; Show(lastdiv);" onmouseout="menudown(help)">HELP!</a>
<div id="space" class=menu style="width: 0; height: 0; left: 0; top: 0"> </div>
<div id="help" class=menu style="left:658px; width: 75px;; top: 25px">
<table bgcolor=#000000 cellspacing=0 cellpadding=1>
<tr>
<td>
<table width=100% cellspacing=0 cellpadding=4 bgcolor=#dddddd>
<tr>
<td align="center"> <a href=abc.php>abc</a></td>
</tr>
<tr>
<td align="center"><a href=faq.php>faq</a></td>
</tr>
<tr>
<td align="center"><a href=about.php>about</a></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<script language=JavaScript1.2>
document.lastdiv=space;
</script>
</body></html>
when my mouse over the link, the menu show up,but when my mouse out, the menu doesn't show down the menudown function doesn't work!
WHY?
Any idea?
Sorry for my english.
gnu2php
Forum Contributor
Posts: 122 Joined: Thu Jul 11, 2002 2:53 am
Post
by gnu2php » Sun Jul 28, 2002 2:20 pm
I don't think it'll work unless you pass a "global" variable to Hide(), since timeout functions seem to require it.
Try this. It sets a global variable "curr_target" to "target":
Code: Select all
function menudown(target){
curr_target=target;
setTimeout("Hide(curr_target)",5000);
}
The only problem is that if you call menudown() again before Hide() is actually called, the curr_target variable is altered.
You might try something like this:
Code: Select all
var timer = 0;
function menudown(target){
if (timer) clearTimeout(timer);
curr_target=target;
timer = setTimeout("Hide(curr_target)",5000);
}
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Mon Jul 29, 2002 8:25 am
for DOM2 there is an
window.event object holding the event informations.
window.event.src contains a reference to the -uhm, well- source
You may use this to avoid the global var.