Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts

    onClick vs onDblClick (hopefully this is the correct forum to post in)

    say i have the following element on my site

    Code:
    <img src="img.jpg" onClick="dothisfunction()" onDblClick="differentfunction()" />
    Whenever i click on the image i receive the onClick function, this is regardless of the number of click and the speed in which i do it.

    is there a way to have an element do something different between single click and double click?

    *note, the double click function is called when i double click IF there is no single click attribute on the element.
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,618
    Thanks
    0
    Thanked 645 Times in 635 Posts
    In Internet Explorer double clicking will trigger the following events:

    mousedown
    mouseup
    click
    mousedown
    mouseup
    click
    dblclick

    Other browsers will trigger the same except for the last event "dblclick" which is an IE proprietary event.

    You will need to write your code in such a way as to cater for this series of events.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •