"VK" <schools_ring@yahoo.com> writes:
[color=blue]
> NN/FF implements a "Russian hills" style: mouse events go first
> up->down (window->deepest element), and right away after that it goes
> down->up (deepest element->window).[/color]
Correct. That is how the event handling model is defined in the W3C
DOM 2 Events specification, and Gecko implements it correctly.
In particular, it's specified here:
<URL:http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-flow>
[color=blue]
> On theory you can handle events during any phase on any level.[/color]
Correct, as long as event propagation isn't stopped before the event
hits that level.
[color=blue]
> On practice this implementation has some major flaws. I don't have
> NN handy right now, but in FF we have:
>
> SomeElement.addEventListener('mouseout', test, true)
>
> This statement supposedly forces test() to capture events on the
> up->down phase.[/color]
Correct. The third argument is also called "capture", and the up->down
phase is called the capture phase.
[color=blue]
> A simple test show that it fails to work. Both
> addEventListener('mouseout', test, true) and
> addEventListener('mouseout', test, false) capture only down->up phase
> (bubbling).[/color]
No. It works fine. Try this:
---
<div id="bar"><div id="baz">XXXX</div></div>
<script type="text/javascript">
var bar = document.getElementById("bar");
bar.addEventListener("click", function(event) {
alert(["up", event.currentTarget.id, event.target.id]); }, false);
bar.addEventListener("click", function(event) {
alert(["down", event.currentTarget.id, event.target.id]); }, true);
var baz = document.getElementById("baz");
baz.addEventListener("click", function(event) {
alert(["hit", event.currentTarget.id, event.target.id]); }, false);
</script>
---
Then click on the "XXXX" :)
[color=blue]
> Eine Frage fuer Million Dollar: what the first phase for anyway?[/color]
The capture phase, not the bubbleing phase.
[color=blue]
> The real killer is here: event object in FF is not exposed to inline
> event capturers!
> <ul onMouseOver="f1()" onMouseOut="f2()"> as well as
> <ul onMouseOver="f1(e)" onMouseOut="f2(e)">[/color]
That didn't work in IE either. In intrinsic event handlers, the event
is available as the variable "event". IE makes it a global variable,
other browsers make it local.
[color=blue]
> gives you undefined for e.[/color]
As it should. Nobody have declared any variable called "e".
[color=blue]
> Thus inline capturers are really good for nothing in FF, except maybe
> for alert("Hello world!") stuff. I don't know where did they get
> such idea, certainly not from my books and not from W3 papers.[/color]
There is no standard for how events are propagated to intrinsic event
handlers, but the "event" variable has been defacto standard since ...
Netscape 2, I think.
[color=blue]
> I also guess that the event object in this case is not exposed neither
> to the user nor to the program core itself. This explains why inline
> capturers randomly fail to work depending on the mouse movement
> direction and even movement speed.[/color]
I have no idea what these failures are, but this is not the reason for
them.
[color=blue]
> This actually answers my question: is there a simple universal way to
> handle events from inline capturers? The answer is: NO, because of FF
> global failure.[/color]
Big words. Now eat them :)
[color=blue]
> For a situation like
> <ul id="UL1">
> <li><a href="javascript
:void(0)">Item 1</a></li>
> <li><a href="javascript
:void(0)">Item 2</a></li>
> <li><a href="javascript
:void(0)">Item 3</a></li>
> </ul>
> the only way to properly handle mouse events from <ul> is to attach
> event handlers on onload, and later study target properties to see if
> this event really from <ul> or from some underlaying element.[/color]
<ul id="UL1" onclick="var tgt = event.target||event.srcElement;//IE sucks
if (tgt == this) { alert('event on UL!'); }">
....
Good luck
/L
--
Lasse Reichstein Nielsen -
lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'