Forum Moderators: open

Message Too Old, No Replies

Javascript double click

is there a way to detect if a textarea is double clicked?

         

nAzGiRl2005

9:14 pm on Aug 29, 2005 (gmt 0)

10+ Year Member



Is there a condition in javascript, that can tell if a textbox has been doubleclicked on?
what I wish to say is the following:

from a popup window:
if (this textarea in the main form is doubleclicked on)
then perform a certain action

Does anyone have any idea how this works?
if so, please let me know. I need urgent help.

thank you,

Nazli

King_Kong

4:29 pm on Aug 30, 2005 (gmt 0)

10+ Year Member



Dead simple..

<textarea onDblClick="alert('Double Clicked')"></textarea>

However its not exactly an intuitive action...

nAzGiRl2005

4:50 pm on Aug 30, 2005 (gmt 0)

10+ Year Member



no, I know how to do that.
My question, however, was if this was possible with Javascript. I don't want to do this in my html code, it has to be javascript.
anyways, forget it.

Don_Hoagie

7:08 pm on Aug 30, 2005 (gmt 0)

10+ Year Member



'onDblClick' is a reference to Javascript. It really is that simple. The complexity lies in what you want to happen once your code recognizes a double-click.

If you don't want to manipulate any HTML to detect a double-click, I suppose you could create a double-click function in an external JS file, and not link it to anywhere. Of course, then it would have absolutely no effect on anything.

That would be a neat trick.

King_Kong

9:55 am on Aug 31, 2005 (gmt 0)

10+ Year Member



you mean like this?

<script>
onload = function () {
document.getElementById("textarea").ondblclick = function () { alert('Double Clicked!') }
}
</script>

then this in the body

<textarea id="textarea"></textarea>