newboy
06-04-2003, 10:11 AM
Hi,
I wanna make a onmouseover event for my "Div" tags that called like this:
Divs[arguments[0]].onmouseover=function(){showMenu(levels[0])}
Divs[arguments[0]].onmouseout=function() {hideMenu(levels[0])}
and I called the functin at first time this way:
<a href="javascript:void(0)" onmouseover="showMenu(0)">menu1</a>
&
<a href="javascript:void(0)" onmouseover="showMenu(1)">menu2</a>
if you move your mouse on "menu1" that will alert "0" then move on "menu2" will alert "1", now when you repeat this
work for Div1, that will alert "1", why? I know levels[0] is a public variable, but What I can do?
thank's a lot.
this is the code:
<html>
<script>
levels=new Array();
function showMenu(){
for(i=0;i<arguments.length;i++){
levels[i]=arguments[i];
}
alert("over: "+arguments[0]);
Divs[arguments[0]].style.visibility='visible';
Divs[arguments[0]].onmouseover=function(){showMenu(levels[0])}
Divs[arguments[0]].onmouseout=function() {hideMenu(levels[0])}
}
function hideMenu(){
Divs[arguments[0]].style.visibility='hidden';
alert("out : "+arguments[0]);
}
function init(){
Divs=document.getElementById('Md').getElementsByTagName('div');
}
</script>
<body onload="init()">
<a href="javascript:void(0)" onmouseover="showMenu(0)">menu1</a>
<a href="javascript:void(0)" onmouseover="showMenu(1)">menu2</a>
<div id="Md">
<div style="visibility:hidden;width:50;left:10;position:absolute">Div 1</div>
<div style="visibility:hidden;width:50;left:50;position:absolute">Div 2</div>
</div>
</body>
</html>
I wanna make a onmouseover event for my "Div" tags that called like this:
Divs[arguments[0]].onmouseover=function(){showMenu(levels[0])}
Divs[arguments[0]].onmouseout=function() {hideMenu(levels[0])}
and I called the functin at first time this way:
<a href="javascript:void(0)" onmouseover="showMenu(0)">menu1</a>
&
<a href="javascript:void(0)" onmouseover="showMenu(1)">menu2</a>
if you move your mouse on "menu1" that will alert "0" then move on "menu2" will alert "1", now when you repeat this
work for Div1, that will alert "1", why? I know levels[0] is a public variable, but What I can do?
thank's a lot.
this is the code:
<html>
<script>
levels=new Array();
function showMenu(){
for(i=0;i<arguments.length;i++){
levels[i]=arguments[i];
}
alert("over: "+arguments[0]);
Divs[arguments[0]].style.visibility='visible';
Divs[arguments[0]].onmouseover=function(){showMenu(levels[0])}
Divs[arguments[0]].onmouseout=function() {hideMenu(levels[0])}
}
function hideMenu(){
Divs[arguments[0]].style.visibility='hidden';
alert("out : "+arguments[0]);
}
function init(){
Divs=document.getElementById('Md').getElementsByTagName('div');
}
</script>
<body onload="init()">
<a href="javascript:void(0)" onmouseover="showMenu(0)">menu1</a>
<a href="javascript:void(0)" onmouseover="showMenu(1)">menu2</a>
<div id="Md">
<div style="visibility:hidden;width:50;left:10;position:absolute">Div 1</div>
<div style="visibility:hidden;width:50;left:50;position:absolute">Div 2</div>
</div>
</body>
</html>