473,396 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ondblclick and onclick together

Dan

How do I catch both ondblclick and onclick on a div?

/Dan

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #1
2 6714
Dan wrote:


How do I catch both ondblclick and onclick on a div?


By putting both events on the div - trivial example:

<div onclick="document.getElementById('cc').innerHTML = 'You clicked';"
ondblclick="document.getElementById('cc').innerHTM L =
'<b>you double clicked</b>';">the result: <span id="cc"></span></div>

However, the first click will execute the "onclick", so if the double
click gets through (as it does in my example) both events will fire
unless the first click does something that immediately causes all
further input to be ignored - say opening a modal dialog like alert.

I can't think of how a double click could get through before the first
single click - but I'm happy to be enlightened.

Fred.
Jul 23 '05 #2
Fred Oz wrote:
I can't think of how a double click could get through before the first
single click - but I'm happy to be enlightened.


You my start a timer on a single click which calls the method to be
executed on a single click. The doubleclick handler should cancel the
singleclick timer (if not allready done) and than call the double click
action.

However, this means that every single click action will be a bit delayed.

Daniel
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ken | last post by:
Does php work with onClick in an html input statement? <HTML> <input type="button" name="add_picture" value="Add another picture" onClick="<?php picture_count(); ?>"> I want to call the...
2
by: Colin Steadman | last post by:
I am creating a simple site with two frame elements. The frame on the left (MENU) contains a menu, and the big frame on the right (PAGE) handles content. The menu frame has an image which loads...
3
by: EviL KerneL | last post by:
Hi - I am working on a survey project which has a next button that takes you to the next set of questions and so on. It does this by means of an OnClick event which takes the answers from the...
3
by: Stefan Finzel | last post by:
Hi what's the right way to add ONCLICK to a form button using javascript? <HTML>... <INPUT ID="RESET" NAME="RESET" TYPE="RESET" VALUE=" Reset ">No onclick is used here <SCRIPT...
2
by: Homa | last post by:
Hi, I have a Datagrid that uses as a shopping cart and have a checkbox template column in it. I can't add both OnCheckedChanged Event and onclick client script for it. I want to do two...
1
by: Simon Wigzell | last post by:
I'm using ondblclick in a text field to load a value from somewhere else into that field. Seem fine on everything except mac products. Any workaround or solution? Thanks!
4
by: phil | last post by:
Hi, I defined a Html button but added the option 'runat="server" ' like this: <form id="form1" runat="server"> <input id="Button1" type="button" value="button" runat="server" onclick="hfd()" ...
10
by: apparker | last post by:
I'm creating a new GUI for a program and it is for a medical exam. There are so many different things to ask someone during a history it wastes too much space to make checkboxes for everything so I...
3
by: chaitanya83 | last post by:
Is it possible to call both events onclick,ondblclick in div tag?
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.