Link to home
Start Free TrialLog in
Avatar of gen228
gen228

asked on

How can I detect which button clicked with onclick event handler.

Hi, if I am using the onclick event handler, how can I detect a right or left mouse click.  I cannot use the onMousedown handler.

-Thanks noijet
ASKER CERTIFIED SOLUTION
Avatar of kanithi
kanithi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
<script language=JavaScript>
function getClick(e)
  {
  if (document.all)
    { alert(event.button); }
  else if (document.layers)
    { alert(e.which); }
  else if (document.captureEvents)
    { alert(document.captureEvents(Event.MOUSEDOWN)); }
  }

document.onmousedown=getClick;
</script>
Avatar of Michel Plungjan
gen228,
No comment has been added lately (309 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: Award points to kanithi http:#7455082

Please leave any comments here within 7 days.

-- Please DO NOT accept this comment as an answer ! --

Thanks,

mplungjan
EE Cleanup Volunteer
Avatar of gen228

ASKER

Thanks for the advice !  I apologize for the delay and thanks for the assist mplungjan !

Thanks