I need help: I'm trying to make a javascript (with not much luck so far).
There are buttons on the page I generate with php, they should work as follows:
If I click the button for less than whatever seconds the link opens like if the button has: onClick="self.location='url'". Else the button is held down for more than whatever seconds the link should open in a new tab like if the button had: onclick="window.open('url');"
It would be great if it could work for links also.
It's probably easy to do, but I have no js knowledge at all and I'm flooded with other stuff I actually know how to do so that is why I ask for Your help. I have already missed my deadline. :(
My goal is to make a php function to create buttons: like : createbutton($name,$link,$class,$delay, ... ); But don't worry about that, I can do that.
Thanks for your help.
An Example here
var counter= 0;
doCount=function(){
setTimeout(function(){
counter++;
},1000);
}
doFunc=function(){
if(counter>2){
//do something if delay is greater than 2 second
}
else{
//do something if delay is less than 2 second
}
}
document.getElementById('myBtn').mousedown = doCount;
document.getElementById('myBtn').mouseup = doFunc;
Try this code
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.