Differentiate between user caused events and script generated events

Discussion in 'Javascript' started by jmpinchot@gmail.com, Apr 27, 2007.

  1. Guest

    Is it possible for an onclick handler for an element to tell the
    difference between a click event that was caused by a mouse click or a
    click event generated by calling document.getElementByID('id').click()?
    , Apr 27, 2007
    #1
    1. Advertising

  2. On Apr 26, 5:27 pm, wrote:
    > Is it possible for an onclick handler for an element to tell the
    > difference between a click event that was caused by a mouse click or a
    > click event generated by calling document.getElementByID('id').click()?


    I don't think so.

    You could do this

    <script type="text/javascript">
    function handleClick(isRealMouseClick) {
    alert(isRealMouseClick);
    }

    handleClick(false);
    </script>

    <div onclick="handleClick(true);">click me</div>

    Peter
    Peter Michaux, Apr 27, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    13
    Views:
    779
    Richard Tobin
    Aug 11, 2004
  2. Jo
    Replies:
    7
    Views:
    495
  3. Bob Weiner
    Replies:
    1
    Views:
    122
    Elton W
    May 6, 2005
  4. KingBEE
    Replies:
    0
    Views:
    132
    KingBEE
    Apr 3, 2004
  5. rhitam
    Replies:
    1
    Views:
    165
    David Mark
    May 13, 2009
Loading...

Share This Page