onclick gets fired even when double clicked

Discussion in 'HTML' started by spinybabler, Aug 7, 2009.

  1. spinybabler

    spinybabler Guest

    Hi,

    Here is my problem: I have a image map. When i click an area on the
    image map, the area is to be highlighted. This highlighting i achieve
    by drawing a div over the image area. I have both click and double
    click events defined for a image area. But when i double click on the
    area, first onclick gets called which results in a div layer drawn
    above the image area and thus double click event never gets called. Is
    there any workaround to fix this?

    Any help would be highly appreciated.

    Thanks a lot.
     
    spinybabler, Aug 7, 2009
    #1
    1. Advertising

  2. spinybabler

    Ivan S Guest

    On 7 kol, 20:13, spinybabler <> wrote:
    > Hi,
    >
    > Here is my problem: I have a image map. When i click an area on the
    > image map, the area is to be highlighted. This highlighting i achieve
    > by drawing a div over the image area. I have both click and double
    > click events defined for a image area. But when i double click on the
    > area, first onclick gets called which results in a div layer drawn
    > above the image area and thus double click event never gets called. Is
    > there any workaround to fix this?
    >
    > Any help would be highly appreciated.
    >
    > Thanks a lot.


    I had similar problem with one online game ... but I don't remember
    solution. :(

    Maybe you should ask this question on comp.lang.javascript group,
    because this is javascript issue, not a html. Or try to find solution
    on Google.




    Ivan
     
    Ivan S, Aug 7, 2009
    #2
    1. Advertising

  3. spinybabler

    spinybabler Guest

    On Aug 7, 2:21 pm, Ivan S <> wrote:
    > On 7 kol, 20:13, spinybabler <> wrote:
    >
    > > Hi,

    >
    > > Here is my problem: I have a image map. When i click an area on the
    > > image map, the area is to be highlighted. This highlighting i achieve
    > > by drawing a div over the image area. I have both click and double
    > > click events defined for a image area. But when i double click on the
    > > area, first onclick gets called which results in a div layer drawn
    > > above the image area and thus double click event never gets called. Is
    > > there any workaround to fix this?

    >
    > > Any help would be highly appreciated.

    >
    > > Thanks a lot.

    >
    > I had similar problem with one online game ... but I don't remember
    > solution. :(
    >
    > Maybe you should ask this question on comp.lang.javascript group,
    > because this is javascript issue, not a html. Or try to find solution
    > on Google.
    >
    > Ivan


    I tried googling but only solution that I found was using setTimeout.
    I made it to work but still it behaves awkwardly. Sometimes double
    click gets called and sometimes it doesn't. The way i did it was to
    setup a function that draws the div to be called after some time (400
    millisecs). If double click gets called before that I remove the
    timeout function call so that the div doesn't get drawn. It works but
    I believe this is a dirty solution and the main thing is that it
    doesn't work all the time.

    Any inputs and directions where I should lead myself to??
     
    spinybabler, Aug 7, 2009
    #3
  4. spinybabler

    richard Guest

    On Fri, 7 Aug 2009 11:13:05 -0700 (PDT), spinybabler
    <> wrote:

    >Hi,
    >
    >Here is my problem: I have a image map. When i click an area on the
    >image map, the area is to be highlighted. This highlighting i achieve
    >by drawing a div over the image area. I have both click and double
    >click events defined for a image area. But when i double click on the
    >area, first onclick gets called which results in a div layer drawn
    >above the image area and thus double click event never gets called. Is
    >there any workaround to fix this?
    >
    >Any help would be highly appreciated.
    >
    >Thanks a lot.



    Look at the possibility of using ondoubleclick instead.
     
    richard, Aug 8, 2009
    #4
  5. spinybabler

    Andy Guest

    "spinybabler" <> wrote in message
    news:...
    > Hi,
    >
    > Here is my problem: I have a image map. When i click an area on the
    > image map, the area is to be highlighted. This highlighting i achieve
    > by drawing a div over the image area. I have both click and double
    > click events defined for a image area. But when i double click on the
    > area, first onclick gets called which results in a div layer drawn
    > above the image area and thus double click event never gets called. Is
    > there any workaround to fix this?
    >
    > Any help would be highly appreciated.
    >
    > Thanks a lot.



    I would use onclick to run the function which immediately starts a clock and
    sets a switch var. If after a short time the switch var has not changed then
    run your div highlight code. If the function is called again before the
    timed event (simulating a double-click) then change the switch var so that
    this time when you reach the "after a short time" event it sees that the
    switch var is different and runs the double-click code instead.

    Make sense?


    Andy
     
    Andy, Aug 8, 2009
    #5
    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. Dan
    Replies:
    0
    Views:
    410
  2. Sydex
    Replies:
    12
    Views:
    6,646
    Victor Bazarov
    Feb 17, 2005
  3. K Viltersten
    Replies:
    0
    Views:
    381
    K Viltersten
    Aug 22, 2009
  4. Manick

    datagrid's itemcommand event gets fired

    Manick, Oct 24, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    195
  5. spinybabler

    onclick gets fired even when double clicked

    spinybabler, Aug 7, 2009, in forum: Javascript
    Replies:
    1
    Views:
    101
    Thomas 'PointedEars' Lahn
    Aug 7, 2009
Loading...

Share This Page