Avoid double-click event when onclick handler shows confirm()/alert().
Fixes #17815, refs #15878.
cleanup variable names etc., refs #17815.