Firefox Port.emit And Port.on Not Working In Extension
I am trying to make a firefox extension. I need to exchange data with the background script(main.js) so I am trying to use port but it doesn't work. //Content.js self.port.on('aler
Solution 1:
The code should have been worker.port.emit and worker.port.on instead of worker.on and worker.emit
pageMod.PageMod({
include: ["https://play.google.com/*"],
contentScriptWhen: 'ready',
contentScriptFile: [data.url("jquery.js"),data.url("jquery.knob.js"),data.url("purl.js"),data.url("content.js")],
contentScriptOptions: {
inUrl: data.url("in.png"),
outUrl: data.url("out.png"),
logoUrl: data.url("logoimage.png")
},
contentStyleFile: [data.url("css/inject.css")],
onAttach: function(worker) {//Ttach
alert("hello there")
worker.port.on("message",function(){
//THIS IS THE CORRECT CODE
worker.port.emit("alert",{message:"Hello"});
})
}
});
Post a Comment for "Firefox Port.emit And Port.on Not Working In Extension"