Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: AW: onMouseDown


Message #1 by =?iso-8859-1?Q?Hans_J=F6rg_Friedrich?= <hans.friedrich@b...> on Thu, 28 Jun 2001 15:05:35 +0200
Hello Kathleen,

I guess (really guessing), your problem has it's origin in the mouseOut
event. For each event would cause the image to stay permanently. But if
you have clicked a button, you will afterwards (most probably) move the
cursor outside.

If so, you could set a flag if the user clicks the button and then check
for this flag in your mouseout-handler. If you move outside when the
user didn't click, you set the color, else, you do nothing.

Finally, you should use the onclick-event rather than onmousedown. This
convention gives the user the opportunity to change his mind and release
the button outside without affecting the action.


Hope this helps

Hans

-----Urspr=FCngliche Nachricht-----
Von: KATHLEEN.M.WHALEN@c...
[mailto:KATHLEEN.M.WHALEN@c...]
Gesendet: Mittwoch, 27. Juni 2001 19:22
An: javascript
Betreff: [javascript] onMouseDown





       I am trying to set something up on my page, that's not quite
       working.  I
       have a navigation bar on the left frame that has several
       buttons.  I have
       rollovers setup to change the button images when the mouse is
       passed over
       and out (onMouseOver, onMouseOut).  I want to set it up so that
       once the
       button is clicked the image changes permanently.

       For instance,
       normal state =3D red button
       mouse over =3D blue button
       mouse click =3D green button

       I want the button to remain green until the next button is
       clicked.
       I thought I could use the onMousedown event handler, but this
       doesn't seem
       to be working (or I'm using it incorrectly.)  Can someone check
       my code
       and let me know where it is I am going wrong?  The button image
       only
       changes momentarily.  The onClick event changes the image
       located in Frame
       #2.  I even tried moving my function inside the onClick event,
       but then
       nothing at all happened.

       <a href=3D"#"
               onMouseOver=3D"rollOver('A','images/buttons/blue.gif');"
               onMouseOut=3D"rollOver('A','images/buttons/red.gif');"
               onMouseDown=3D"rollOver('A','images/buttons/green
       button.gif');"
               onClick=3D"doPic('images/glossary/a.gif');">RED BUTTON
       IMAGE GOES
       HERE</A>

       -----------------ROLLEOVER FUNCTION-------
       function rollOver(tagName, fileName) {
               document.images[tagName].src=3DfileName;
       }

       Kathleen M. Whalen
       U.S. Customs Service
        (xxx) xxx-xxxx

  Return to Index