I am developing an add-on which opens a new window from a right click context menu option. When I attempt to install and use the add-on outside of a debugging window the new window is always blocked by my popup blocker and any exception I add does not prevent this. How do you normally utilize a new window with content from a web source in a FireFox add-on?
My index.js file is setup like this:
var contextMenu = require(“sdk/context-menu”);
var menuItem = contextMenu.Item({
label: “Right Click Menu Option”,
context: contextMenu.SelectionContext(),
contentScript: ‘self.on(“click”, function () {’ +
’ var text = window.getSelection().toString();’ +
’ self.postMessage(text);’ +
’});’,
image: self.data.url(“icon16.png”),
onMessage: function (selectionText) {
var highlightedtext = selectionText;
var worker = tabs.activeTab.attach({
contentScriptFile: self.data.url(“content-script.js”)
});
worker.port.emit(“rightClickText”, highlightedtext);
}
});
My content-script.js which opens the window is setup like this:
// content-script.js
self.port.on(“rightClickText”, openEncryptionPage);
function openEncryptionPage(unecryptedtext) {
var strWindowFeatures = “menubar=no,location=yes,dialog=yes,toolbar=no,titlebar=no,resizable=yes,scrollbars=yes,status=no,width=610,height=690”;
window.open(‘https://someurl.com’, “NewWindow”, strWindowFeatures);
}