Is there a way to create a click event(or effect) that repeat the last click.
I need no jQuery nor Mootools nor any other javascript lib, just in pure JavaScipt.
Is there a way to create a click event(or effect) that repeat the last click.
I need no jQuery nor Mootools nor any other javascript lib, just in pure JavaScipt.
See createEvent and dispatchEvent and an example usage shown here: Is it possible to trigger a link's (or any element's) click event through JavaScript?
You want to Google for 'firing events manually in JavaScript' or 'simulate events in JavaScript'.
Since you captured the last event, you know what it is and can feed it into a function. Put a timer or counter on it to stop after a specified period of time or repeats.
Here is some sample code:
function fireEvent (element, event) {
if (document.createEventObject) {
// dispatch for IE
var evt = document.createEventObject ();
return element.fireEvent ('on' + event, evt)
} else{
// dispatch for firefox + others
var evt = document.createEvent ("HTMLEvents");
evt.initEvent (event, true, true ); // event type, bubbling, cancellable
return !element.dispatchEvent (evt);
}
Check this site:
http://lifescaler.com/2008/04/simulating-mouse-clicks-in-javascript/