Netscape 7.02 onmouseout not fire up

K

Kevin Ly

Consider the test case below. The onmouseout event does NOT fire when
my mouse/cusor is moved off the left side of the browser. It does if
it is moved off the top, bottom, and the right side that HAS THE
SCROLLBAR (does not if the right side does not have the scrollbar on).

Also, if you move around each "this is a test" line, the onmouseout
event fires. How odd? Fortunately, I can have logic to handle this.

The big problem is why the onmouseout event does not fire when the
cursor is moved off the left side of the browser (and right side if
there is no scroll bar)? Is this a known bug or something I don't
know? Is there a way to get around this?

<html>
<head>
<title>test</title>
<script>
function foo(e)
{
alert('mouseout');
}
document.addEventListener("mouseout", foo, true);
</script>
</head>
<body>
This is a test<br>
This is a test<br>
This is a test<br>
</body>
</html>

Any info would be appreciated!

Kevin
 
M

Michael Winter

Consider the test case below. The onmouseout event does NOT fire when
my mouse/cusor is moved off the left side of the browser. It does if
it is moved off the top, bottom, and the right side that HAS THE
SCROLLBAR (does not if the right side does not have the scrollbar on).

The cursor only has to move into the window border to fire the mouseout
event. This works correctly in Mozilla, so I would expect it do so in
Netscape, too. However, I don't have Netscape at hand to test it.
Also, if you move around each "this is a test" line, the onmouseout
event fires. How odd? Fortunately, I can have logic to handle this.

It's not odd at all, I just don't think you understand the event system
properly.

The last argument in the addEventListener() method specifies whether the
listener should "capture" events or not. What normally happens in the
event flow is that when an event occurs, the listeners on the target
element are fired. Once all of the listeners for that event type have been
fired, the listeners for that same type on the parent element are fired.
This known as bubbling, and it occurs all the way up the document tree
until the document object is reached. Once the listeners have been fired
there, the event is removed.

If you specify true for the third parameter, the process of event
capturing occurs before all of that. Event capturing works in reverse of
bubbling. That is, it starts at the document object, and works its way
down the tree in a direct path towards the target element. All elements
that are in that path have their listeners fired. There is another
difference here, too: when capturing is in progress, only listeners that
were registered as capturing listeners are fired. Normal listeners are
not. Finally, note that capturing event listeners will not fire when an
event of their type is fired on the element they are attached to. They
only fire when the event is triggered on an element below them in the tree.

Because you are registering a capturing listener on the document node, it
executes for *every* mouseout that occurs in the nodes below it.

There's also halting propagation and event cancellation to consider, but
they're not the subject here. :)
The big problem is why the onmouseout event does not fire when the
cursor is moved off the left side of the browser (and right side if
there is no scroll bar)? Is this a known bug or something I don't
know? Is there a way to get around this?

As Mozilla and Netscape are so closely related, I'm surprised that Mozilla
doesn't exhibit the same behaviour. Have you tried looking at the bug list
for Mozilla? Perhaps it's been fixed for Mozilla and not for Netscape as
it's based on an earlier version.

Now for the HTML:

Valid documents must[1] have a document type declaration (DTD). You should
then validate your document against the DTD. You can't reliably script an
invalid document, especially with DOM methods.

DTDs:

<URL:http://www.w3.org/TR/html401/struct/global.html#h-7.2>

Validator:

<html>
<head>
<title>test</title>
<script>

The type attribute is required for SCRIPT elements:

function foo(e)
{
alert('mouseout');
}
document.addEventListener("mouseout", foo, true);

As I described above, you probably mean for the last argument to be false.
</script>
</head>
<body>
This is a test<br>
This is a test<br>
This is a test<br>

The validator will tell you that the text is invalid at that location. You
need to place it inside a P or DIV element.
</body>
</html>

Mike


[1] Don't kick up a fuss about this. It's for emphasis if nothing else.
 
K

Kevin Ly

Michael, thanks for the inputs. I tried fixing up the sample HTML
conforming to the DTD standard, and the problem still exists under
Netscape 7.02. At this point, I don't have a workaround for this
problem.

I did download the latest Netscape 7.1, and it worked under Netscape
7.1. Perhaps, it's a bug under Netscape 7.02. :-(

Kevin

Michael Winter said:
Consider the test case below. The onmouseout event does NOT fire when
my mouse/cusor is moved off the left side of the browser. It does if
it is moved off the top, bottom, and the right side that HAS THE
SCROLLBAR (does not if the right side does not have the scrollbar on).

The cursor only has to move into the window border to fire the mouseout
event. This works correctly in Mozilla, so I would expect it do so in
Netscape, too. However, I don't have Netscape at hand to test it.
Also, if you move around each "this is a test" line, the onmouseout
event fires. How odd? Fortunately, I can have logic to handle this.

It's not odd at all, I just don't think you understand the event system
properly.

The last argument in the addEventListener() method specifies whether the
listener should "capture" events or not. What normally happens in the
event flow is that when an event occurs, the listeners on the target
element are fired. Once all of the listeners for that event type have been
fired, the listeners for that same type on the parent element are fired.
This known as bubbling, and it occurs all the way up the document tree
until the document object is reached. Once the listeners have been fired
there, the event is removed.

If you specify true for the third parameter, the process of event
capturing occurs before all of that. Event capturing works in reverse of
bubbling. That is, it starts at the document object, and works its way
down the tree in a direct path towards the target element. All elements
that are in that path have their listeners fired. There is another
difference here, too: when capturing is in progress, only listeners that
were registered as capturing listeners are fired. Normal listeners are
not. Finally, note that capturing event listeners will not fire when an
event of their type is fired on the element they are attached to. They
only fire when the event is triggered on an element below them in the tree.

Because you are registering a capturing listener on the document node, it
executes for *every* mouseout that occurs in the nodes below it.

There's also halting propagation and event cancellation to consider, but
they're not the subject here. :)
The big problem is why the onmouseout event does not fire when the
cursor is moved off the left side of the browser (and right side if
there is no scroll bar)? Is this a known bug or something I don't
know? Is there a way to get around this?

As Mozilla and Netscape are so closely related, I'm surprised that Mozilla
doesn't exhibit the same behaviour. Have you tried looking at the bug list
for Mozilla? Perhaps it's been fixed for Mozilla and not for Netscape as
it's based on an earlier version.

Now for the HTML:

Valid documents must[1] have a document type declaration (DTD). You should
then validate your document against the DTD. You can't reliably script an
invalid document, especially with DOM methods.

DTDs:

<URL:http://www.w3.org/TR/html401/struct/global.html#h-7.2>

Validator:

<html>
<head>
<title>test</title>
<script>

The type attribute is required for SCRIPT elements:

function foo(e)
{
alert('mouseout');
}
document.addEventListener("mouseout", foo, true);

As I described above, you probably mean for the last argument to be false.
</script>
</head>
<body>
This is a test<br>
This is a test<br>
This is a test<br>

The validator will tell you that the text is invalid at that location. You
need to place it inside a P or DIV element.
</body>
</html>

Mike


[1] Don't kick up a fuss about this. It's for emphasis if nothing else.
 

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

No members online now.

Forum statistics

Threads
474,433
Messages
2,571,683
Members
48,796
Latest member
Greg L.

Latest Threads

Top