Redirect when click double click at single button


Redirect when click double click at single button



I try to find Q&A related to my question. But I couldn't find. I have created a code where if user click double or multi click at single link then he will redirect to error page.



My Code is



var doubleClick = false;
function myWillPageRedirect() {
if(!doubleClick) {
doubleClick = true;
window.open("errorPage.html");
}
}



But this is not working. Why?
I want to create a secure page generally we can see in some bank or financial website.
I want to create 'if user click window back button then he will redirect to error page.' OR if if click refresh button then same action will perform and redirect to error page. ..


'if user click window back button then he will redirect to error page.'


error page.



If this all code can make in Linux server backend code. It would be great.
Please help. I am not saying to some create code for me , I am asking for help to some correct my code above or bit extra help to make them secure.



Thank you .





You can nest click events, write one click event into another and if the second click event is fired, redirect to another page. You can also set timeout event for that click event so that it works only like the actual double and not like two separate clicks
– Code_Ninja
Jul 3 at 7:27


click


click


click


timeout


clicks




1 Answer
1



HTML:


<a href="#" ondblclick="myWillPageRedirect()">Double-click me</a>



JS:


if(performance.navigation){ //Check if the page was refreshed
if( performance.navigation.type === performance.navigation.TYPE_RELOAD ){
myWillPageRedirect();
}
}

function myWillPageRedirect() {
window.open("errorPage.html");
}

window.onhashchange = function() { //Check if the url has changed (in case of pressing back button)
myWillPageRedirect();
}



More infos about Performance.navigation





PLease convert this code in to server side language. I means nobody can see in page source.
– Arjit
Jul 3 at 8:48






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

api-platform.com Unable to generate an IRI for the item of type

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?