Skip to content Skip to sidebar Skip to footer

Firefox Addon That Reacts On Click (left)

I am just started to create firefox add on. My first try was to capture the users left click event and display an alert. but this isn't working: window.addEventListener('click', fu

Solution 1:

That won't work, mainly because your main.js does not have direct access to the window. This code example adds a click event listener to all open tabs:

require('sdk/page-mod').PageMod({
    include: ["*"],
    contentScript: 'window.addEventListener("click", function(e) { alert("blub"); }, false);',
    attachTo: ["existing", "top"]
});

I really recommend you look at the documentation for the add-on SDK to get started, there are some basic concepts you should learn so you don't get frustrated:

https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/index.html#getting-started

Post a Comment for "Firefox Addon That Reacts On Click (left)"