Code: Select all
window.addEventListener("click", function() { alert("Event Encountered!"); }, true);Edit: I tried using mousedown and mouseup but it keeps giving me the same result
Moderator: General Moderators
Code: Select all
window.addEventListener("click", function() { alert("Event Encountered!"); }, true);target.addEventListener(type, listener, useCapture);
If true, useCapture indicates that the user wishes to initiate capture. After initiating capture, all events of the specified type will be dispatched to the registered listener before being dispatched to any EventTargets beneath it in the DOM tree. Events which are bubbling upward through the tree will not trigger a listener designated to use capture.
Code: Select all
window.addEventListener("load", function() { ffSampleExtension.init(); }, false);
var ffSampleExtension = {
init: function() {
var appcontent = document.getElementById("appcontent"); // browser
if(appcontent)
appcontent.addEventListener("DOMContentLoaded", ffSampleExtension.onPageLoad, true);
var messagepane = document.getElementById("messagepane"); // mail
if(messagepane)
messagepane.addEventListener("load", function () { ffSampleExtension.onPageLoad(); }, true);
},
onPageLoad: function(aEvent) {
window.top.addEventListener("click", function() { ffSampleExtension.logData(); }, false);
}
}
Code: Select all
messagepane.addEventListener("load", function () { ffSampleExtension.onPageLoad(); }, true);Code: Select all
messagepane.addEventListener("load", ffSampleExtension.onPageLoad, true);I reread the MDC, and it looks like I was wrong on event listeners being duplicated.how do I check for an event listener if it is already present?
EDIT EDIT: if and only if the EventListeners are IDENTICAL the old ones are discarded.https://developer.mozilla.org/En/DOM/Element.addEventListener wrote:If multiple identical EventListeners are registered on the same EventTarget with the same parameters, the duplicate instances are discarded. They do not cause the EventListener to be called twice, and since the duplicates are discarded, they do not need to be removed manually with the removeEventListener method.
Code: Select all
logData: function() {
var flag = 1;
if(flag == 1) {
var currentTime = new Date();
data = currentTime.getHours()+":"+currentTime.getMinutes()+":"+currentTime.getSeconds()+"\n";
ffSampleExtension.writeToFile(data);
flag = 0;
}
},