Thank you.
Either onmousedown or onclick works, it is just a matter of knowing how the various events will fire and it might change a bit browser to browser.
I write for a corporate intranet with a company standard of IE5.5+. We do not code for other browsers as no PC in the company should be using anything else. But I try to err on the side of caution with some things when possible.
I ran into a lot of trouble with mouse events trying to make my own scrollable windows.
With a draggable object you would click down on it to start dragging but if your mouse pointer strayed off the object while the button is still down you would lose the onmouseup event because the pointer is no longer on the object and the object would continue to be dragged around the screen until you clicked it again. It became a horrible mess to figure out all the possible events and combinations and trying to determine what would suffice for my needs without ending up with unusual consequences. One mouse event can override another causing it not to fire.
For instance. In Windows, if you click on an application button but move your mouse off the button before releasing then the button never executes. It depends on how the app is written of course but it is something you can test easily enough to see the effect.
In this code though suppose onmousedown was used to change the image source. You would still need to determine whether to display the hover or non-hover version. If you change to the standard button then it would not show the hover effect until you moved off and back onto it again so the effect ends up pretty much the same, just a different trigger.
I would have to test it both ways to see if one was more susceptible to failure due to other mouse events overriding the ones needed. So my only reason at this point is that I use onclick more often so it was the first one I thought of.
Paranoid? ME?? WHO WANTS TO KNOW????