js; event cascading; onmousedown etc
Posted on 2003-11-05
Another question that doesn't exist according to the books.
This is one problem expressed in two fashions.
Mouse events are happening twice, how to I make the first hook eat the event?
<a href="./somewhere.html" onmousedown="goSomeWhere();" ... >Go somewhere</a>
where goSomeWhere() is a wrapper function, that moves the window to ./somewhere.html, and does some user interface thingies. The goSomeWhere() *has* to do the page move, as it applies the changes to the newly loaded page.
<span id="span1" onmousedown="anotherWrapper('a1');" ... > <a id="a1" onmousedown="goSomeWhere();"> ...
It is claimed that many users lack accuracy with mice, so I put the spans round the links to increase the target area, for them to hit. My pages are automatically generated, and anotherWrapper() is a utility function that works out what the inner elements are, and invokes them. If the inner element has a onmousedown hook, it runs it; if there is a href is jumps down it.
The problem is, if you click on the link both goSomeWhere() and anotherWrapper() are called.
for 1: goSomeWhere deletes the href attribute, but this seems dangerous.
I just tried making onmousedown hook into onclick, but this crashes moz
for 2: add a variable, to act as a mutex, so only one function happens.
There must be a better way of doing this. Both the functions return true, which is supposed to suppress further activity, but it ain't.
this is some what long post