onclick gets fired even when double clicked

S

spinybabler

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

Ivan S

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
 
S

spinybabler

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??
 
R

richard

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

Andy

spinybabler said:
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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top