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

problem onmouseout event in div tag

Status
Not open for further replies.

greyone

Programmer
Dec 14, 2000
200
CA
i have a div tag which has a id and the style attributes for it are as below. Now i 'm running a for loop to write an array of elements on the page and putting each element in a table so that i can have hover effect on each one of them as seen below.
Now my problem is that onmouseout i want the layer to dissapear. i did this but as soon as i move over the elements the layer dissapears please help

<div id=dropmenu0 style=&quot;position:absolute;left:100;top:100;background-color:#CCCCCC;width:150;visibility:hidden;border:1px solid black ;padding:0px&quot; onmouseover= some hide function>

<script language=&quot;JavaScript1.2&quot;>
if (document.all)
dropmenu0.style.padding=&quot;1px&quot;
estr='<table border=0 width=&quot;150&quot; bordercolor=black cellpadding=&quot;1&quot; cellspacing=&quot;0&quot;>'
estr+='<tr><td align=&quot;left&quot; class=menu onmouseover=this.style.background=&quot;#FF0000&quot; onmouseout=this.style.background=&quot;#CCCCCC&quot;>'
for (i=0;i<menu1.length;i++)
document.write(estr + menu1+'</td></tr></table>')

</script>
</div>
 
your code says onmouseover=some hide function - aren't you trying to hide onmouseout jared@aauser.com
 
well yes but the mouse out behaves very differently since when my mouse is on the layer, the layer seems to dissapear. i don;t want it to hide until my mouse is out of the layer but this dose'nt seem to happen. Please help
 
this is not the best way of doing this, but if you need a quick and dirty fix, here ya go (tested on IE5.5):

<script>
var Global_currmouseover = document.body

function mouseIn()
{
Global_currmouseover=window.event.srcElement
}

function mouseOut()
{
setTimeout(&quot;test()&quot;,1000)
}

function test()
{
if(Global_currmouseover.className!=&quot;menu&quot;)
{
dropmenu0.style.visibility='hidden'
}
}

document.onmouseover = mouseIn
</script>

</head>

<body>


<div id=dropmenu0 class=&quot;menu&quot; style=&quot;position:absolute;left:100;top:100;background-color:#CCCCCC;width:150;border:1px solid black ;padding:0px&quot; onmouseout=&quot;mouseOut(this)&quot;>

<script>
menu1=[&quot;Turbo&quot;,&quot;Dogma&quot;,&quot;Jive&quot;]
if (document.all){
//dropmenu0.style.padding=&quot;1px&quot;
estr='<table border=0 width=&quot;150&quot; bordercolor=black cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;>'
estr+='<tr><td align=&quot;left&quot; class=&quot;menu&quot; onmouseover=&quot;this.style.background=\'#FF0000\'&quot; onmouseout=&quot;this.style.background=\'#CCCCCC\'&quot;>'
for (i=0;i<menu1.length;i++)
{document.write(estr + menu1+'</td></tr></table>');}
}
</script>
</body>

jared@aauser.com
 
thanks a lot pal it worked. that was really great..i tested it in IE4 and it worked but i still have to figure out a way to do this in Netscape.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top