I am developing an extension where I need to get notified whenever an iframe is loaded and ready. I used page-mod
but I don't get the expected output. This is my code:
var data = require("sdk/self").data;
var pageMod = require("sdk/page-mod");
pageMod.PageMod({
include: ['*'],
contentScriptFile: data.url("pageNavData.js"),
contentScriptWhen: "ready",
attachTo: ["frame"],
onAttach: function(worker) {
worker.port.on("gotElement", function(elementContent) {
console.log(elementContent);
});
}
});
And pageNavData.js
is:
self.port.emit("gotElement", document.location.href);
Can anybody see what is wrong with this?