I do not understand at all what your are saying about Windows waiting
eventual 2nd click.
That's OK: a realized non-understanding is the first important step to
the knowledge :-)
In Windows OS (and some other OS) there is a OS-level click filter.
That is a process running on the background of all open applications.
This process - by applying special neuristic and by studying the type
of clicked object - is sorting out occasional double clicks and real
double clicks: for the improved user experience. Say if you double
clicked a submit button: the process presumes (rather reasonably IMHO)
that you meant just to click once, not to submit the form twice but
very quickly :-) Respectively the application gets a refactored event:
single click instead of double click.
Users are making double clicks instead of single ones left and right:
because they accustomed to double click on everything while using their
desktop. Without some doubleclick filter what would be a disaster.
It means - besides everything else - that in your web-applications you
*never* use and never relay on ondoubleclick handlers: they are kept
exclusively for legacy purposes.
In application to HTML button and IE it means that with trained fingers
one can quickly click a button 100 times but the application will get
only 50 single clicks. The system filter will treat your 100 clicks as
50 occasional double clicks and it will refactor them into 50 single
clicks.
If you want to see it in action, below is the code to play with. It is
essentially the OP's code: I just got rid off ++innerHTML and overall
brought it to a more conventional programming style.
Click the button with different speed. Then change your system settings
(must be Windows OS). Manually altering registry can be a dangerous
doing, so I would suggest to use unstead freely available TweakUI util
instead. On TweakUI go to "IE" tab and check off "Detect accidental
double-clicks". As it's a system setting, you'll have to restart
Windows after that. Click the button again to see the changes. Do not
forget to check it on and restart after you are done.
Please note that in any case accesskey (Alt+i / Apple+i) works just
fine with any speed without loosing events. It is because there is not
"ondoublekeypress" event so the system doesn't check it for the
correctness.
What workarounds can be suggested Web-wise?
1) For counters with a narrow range of values (0-10 or around) that can
be easily disregarded. "Click masters" will just have to make a couple
or so extra clicks. In any case do not forget to provide accesskey for
the counter.
2) For counters with a larger range of values click counters should not
be used: use sliders instead.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html401/loose.dtd">
<html>
<head>
<title>doubleclick</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<script type="text/javascript">
var out = null;
var counter = 0;
function init() {
out = document.getElementById('out');
}
window.onload = init;
</script>
</head>
<body>
<p id="out">0</p>
<p><button type="button" accesskey="i" onclick="
out.innerHTML = ++counter;
"><u>I</u>ncrement</button></p>
</body>
</html>