Earlier quoted context omitted.
Seriously? window.setInterval(function(){ Array.prototype.forEach.call(document.querySelectorAll('a'),function(i) {i.dispatchEvent(event)})},1000);
I was going for quick and dirty. $(foo).click() was available so why not use it?
Will you drown?
51–60 of 145 posts
Re: Will you drown?
#52Re: Will you drown?
#53Re: Will you drown?
#54Re: Will you drown?
#55Thats the message I got from it. Beautiful.
Re: Will you drown?
#56Play automatically: setInterval(function(){ $("a").click() }, 100) (Edit: Yes, this leads you through a very fast, very bad life. Play manually and have a better life.)
fireEvent = function(element){
var event; // The custom event that will be created
if (document.createEvent) {
event = document.createEvent("HTMLEvents");
event.initEvent("click", true, true);
} else {
event = document.createEventObject();
event.eventType = "click";
}
event.eventName = "name-of-custom-event";
if (document.createEvent) {
element.dispatchEvent(event);
} else {
element.fireEvent("on" + event.eventType, event);
}
}
setInterval(function(){
Array.prototype.forEach.call(document.querySelectorAll('a'),function(d){
fireEvent(d);
})
}, 1000);Re: Will you drown?
#57Play automatically: setInterval(function(){ $("a").click() }, 100) (Edit: Yes, this leads you through a very fast, very bad life. Play manually and have a better life.)
nope, that wont work at all. Even if you add jquery manually, this won't work at all. The correct one should be fireEvent = function(element){ var event; // The custom event that will be created if (document.createEvent) { event = document.createEvent("HTMLEvents"); event.initEvent("click", true, true); } else { event = document.createEventObject(); event.eventType = "click"; } event.eventName = "name-of-custom-event…
Re: Will you drown?
#58Play automatically: setInterval(function(){ $("a").click() }, 100) (Edit: Yes, this leads you through a very fast, very bad life. Play manually and have a better life.)
nope, that wont work at all. Even if you add jquery manually, this won't work at all. The correct one should be fireEvent = function(element){ var event; // The custom event that will be created if (document.createEvent) { event = document.createEvent("HTMLEvents"); event.initEvent("click", true, true); } else { event = document.createEventObject(); event.eventType = "click"; } event.eventName = "name-of-custom-event…