Using an alert in the Firefox add-on builder -
i'm trying write first firefox extension using ff add-on builder. don't understand why seems code isn't running @ neither alert
pops up. why doesn't alert("main");
create popup?
main.js
alert("main"); var data = require("sdk/self").data; var pagemod = require("sdk/page-mod"); pagemod.pagemod({ include: "*", contentscriptfile: data.url("noredirectlinks.js"), contentscriptwhen: "ready" });
noredirectlinks.js
alert("content script"); var alllinks = document.getelementsbytagname("a"); (var i=0, il=alllinks.length; i<il; i++) { elm = alllinks[i]; if (elm.getattribute("onclick")) { elm.onclick = null; } if (elm.getattribute("onmousedown")) { elm.onmousedown = null; } }
the alert
in main.js
cannot show in browser. main addon code has not access browser page. access content, have use content scripts (as second script).
the alert
in noredirectlinks.js
should work. first test again without alert
in main.js
. must sure file located in data
folder. case?
there error in code didn't provide explain why addon not executed. there other code or everything?
Comments
Post a Comment