admin管理员组

文章数量:1386750

I already have a lot of AJAX code written for a web app and didn't take into account the problems that double clicks on some things can cause. I already implemented an "inprogress" variable for sensitive AJAX calls so that it won't be messed up by double clicking by the user but I am wondering if there is a simple way to just disable all double clicks anywhere (in any element) within the entire body of the web page rather than having to do it individually for each specific element.

Thanks for any advice

I already have a lot of AJAX code written for a web app and didn't take into account the problems that double clicks on some things can cause. I already implemented an "inprogress" variable for sensitive AJAX calls so that it won't be messed up by double clicking by the user but I am wondering if there is a simple way to just disable all double clicks anywhere (in any element) within the entire body of the web page rather than having to do it individually for each specific element.

Thanks for any advice

Share Improve this question asked May 6, 2011 at 1:14 RickRick 17k35 gold badges113 silver badges163 bronze badges 2
  • did you actually mean 'double-clicking' in the meaning of two clicks w/ almost no pause between them, or clicking 2+ times on a button that is wired to an ajax call and thus would add another call on top of the old on, and so on....? – ampersand Commented May 6, 2011 at 2:45
  • 1 I mean double clicking like when you have to double click something on a windows desktop icon to open an application / file. While I don't do it myself, some of our users have problems with this action being ingrained in them so they double click everything on the web app – Rick Commented May 6, 2011 at 20:43
Add a ment  | 

3 Answers 3

Reset to default 5

Try something crazy like this:

$("*").dblclick(function (event)
{
    event.preventDefault();
});

In theory, it would capture the double-click event on any element and then basically do nothing (cancels the default action).

$('*').dblclick(function(event) { event.preventDefault(); return false; });

Should handle it, however there is probably a better solution out there.

If you havn't bound events to double click, double click will do nothing. It is event of its own.
Click and DoubleClick are different events.

本文标签: JavaScriptJQuerydisabling all double clicks anywhere within body of web pageStack Overflow