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

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.