Mouse events within a DIV layer and Netscape/Mozilla

  • Thread starter Jean-Gael GRICOURT
  • Start date
J

Jean-Gael GRICOURT

I am trying to capture mouse events when entering and leaving a DIV
layer. This test code works fine with IE 6.0 and Opera 7.21 but fails
with Mozilla/Netscape. The strange thing is that the mouse events
respond continuously whenever the mouse is moving inside the DIV area.

Does anybody have a clue about what is happenning ?

J2G


==== TEST CODE ====

<html>
<head>
<script type=text/javascript>
function show() {
nbIn=0;
nbOut=0;
document.getElementById('AREA').style.visibility = 'visible';
}

function areaIn() {
nbIn++;
window.status = "out: " + nbOut + " in: " + nbIn;
}

function areaOut() {
nbOut++;
window.status = "out: " + nbOut + " in: " + nbIn;
}

</script>
</head>
<body>

<a href="javascript:show()">SHOW DIV</a>
<p>

<div id="AREA" size=5 style="visibility: hidden"
onmouseover="javascript:areaIn()" onmouseout="javascript:areaOut()">
<select size=5>
<option>value01
<option>value02
<option>value03
<option>value04
<option>value05
<option>value06
</select>
</div>

</body>
</html>
 
M

Martin Honnen

Jean-Gael GRICOURT said:
I am trying to capture mouse events when entering and leaving a DIV
layer. This test code works fine with IE 6.0 and Opera 7.21 but fails
with Mozilla/Netscape. The strange thing is that the mouse events
respond continuously whenever the mouse is moving inside the DIV area.

Does anybody have a clue about what is happenning ?

Yes, the events mouseout/mouseover fire whenever the mouse moves
over/out any element, your div has a child element, the <select>, which
has child elements, the <option> elements, and when you move your mouse
over the select element then mouseout for the <div> is fired and
mouseover for the <select>. And events bubble, so any events happening
on the <select> or the <option> bubble up to the <div> and fire your
onmouseover/onmouseout handler. See
http://www.faqts.com/knowledge_base/view.phtml/aid/1606/fid/145
for a solution.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top