Created
April 1, 2016 09:42
-
-
Save JavaScript-Packer/7c09491ef30652e5e5f856fb549ed394 to your computer and use it in GitHub Desktop.
Triple clicker JavaScript function, click 3 times fast! Adjust to higher like four or five clicks if you want!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<h1 onclick="window.scroll(0,7000)"><u style="color:blue">Click HERE to go to bottom!</u></h1> | |
<script> | |
window.addEventListener('click', function (x) { | |
if (x.detail === 3) { | |
window.scroll(0,0); | |
} | |
}); | |
/* MINIFIED | |
window.addEventListener("click",function(x){if(3===x.detail)window.scroll(0,0)}); | |
*/ | |
</script> | |
<p><hr size="6666"></p> | |
<h1>You can TRIPLE CLICK anywhere to get back to the top of the page @ any time!</h1> | |
<h2>A <a href="http://www.whak.com">WHAK.com</a> JavaScript function gets called!</h2> | |
</body> |
where can I make it so it clicks 4 times
How do I enable it?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's a very nice and short implementation,
(although it is buggy in Internet-Explorer, it beats counting clicks and using a timer...)
I've personally wasn't even aware of that attribute :]
but Google helped me by directing me here (at first..) and then:
https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail
https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event
Since triple-click as some default uses (such as applying selection for an entire block of text or row),
you may add
x.preventDefault();
1 at first (optional).Thanks for the example :]