js; event cascading; onmousedown etc

hi peoples,
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.
The plain href is required for people with Javascript disabled.

<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.

potentail solutions:
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

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Two comments.

1. Why not just just make the links bigger with CSS? You can increase their size and/or margins and/or padding just like you can with any other element.

2. Trapping onmousedown as opposed to onclick would annoy the hell out of me if I were using your site.

You might want to look at attachEvent() and addEventListener() and how to cancel event-bubbling once an event's been noticed.

DeeperDarkerAuthor Commented:
Z: 2. Trapping onmousedown as opposed to onclick would annoy the hell out of me if I were using your site.

how could you tell?
unless you tried drag-click.
>> Mouse events are happening twice, how to I make the first hook eat the event?
event.cancelBubble = true or something, I guess
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

> unless you tried drag-click.

Exactly! I make frequent use of Mozilla's ability to drag a link to the tabbar in order to open a link in a new tab. This would also interfere with users wishing to right-click/ctrl-click/click-hold to get a context menu for opening the link in a new browser window or other legitimate pruposes.
DeeperDarkerAuthor Commented:
I rebuilt the pages with the larger anchor element (with CSS), as Zontar's  suggestion.
This cancels point 2.

The onmousedown is random paranoia, about wanting my code to run before whatever the browser does by default.
During the rebuild I moved the onmousedown to onclick

makC: [event.cancelBubble = true] what browsers support this?   I'm posting this to you (rather than reading), as the different browsers have different event models.  

Does anyone know whether onclick will suppress the traditional href on an anchor?   (I mean in a reliable consistent fashion)
You could use some JavaScript to rewrite the href atttributes:

<script type="text/javascript">
window.onload = rewriteHrefs;

function rewriteHrefs()
  for(var i = 0; i < document.links.length; i++)
    document.links[i].href = "javascript:goSomewheret(\"" + document.links[i].href + "\");";

I pulled a similar stunt a couple of years ago... you wouldn't even need the onclick handlers, perhaps?

If you only want to rewrite certain links, give them a class attribute and test document.links[i].className.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DeeperDarkerAuthor Commented:
Actually its just one link, that flips between different indexes.

In opera the "open in new window" gesture works in conjunction to onclick
doesn't Moz have this level of thoroughness?

will apply this.
points for you Zontar ;-)
You can get a mouse-gestures add-on for Moz, but I could never warm to them in Opera, so I've not tried it. Could be the fault of our cats bumping my elbow all the time.

Ta. :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.