Reputation: 3296
I am developing an extension for Firefox that needs to open a standard Javascript popup window that can be a custom size. I have looked all around and I can't seem to figure out how to do it. My code for a contextual menu works good, but it seems like Firefox is blocking the window.open
snippet needed to accomplish this.
Is there a way todo it via XUL, or any other SDK modules?
Upvotes: 1
Views: 1675
Reputation: 10377
If you want open not a popup window but panel, here's an example:
var self = require("sdk/self");
var panels = require("sdk/panel");
var panel = panels.Panel({
contentURL: self.data.url("panel.html")
// , onHide: handleHide
});
require("sdk/context-menu").Item({
label: "Open Window",
contentScript: 'self.on("click", function (node, data) {' +
' self.postMessage(node.innerHTML);' +
'});',
onMessage: function (data) {
console.log('posted retrieved: '+data);
panel.show();
}
});
And some reference
Upvotes: 1
Reputation: 507
You can also use:
`<popupset>
<panel id="some">
</panel>
<popupset>`
In the JavaScript write:
document.getElementById('some').openPopup(...)
Upvotes: 0
Reputation: 2602
We need a bit more details, here's what I think you're going for.
require("sdk/context-menu").Item({
label: "Open Window",
contentScript: 'self.on("click", function (node, data) {' +
' window.open("http://stackoverflow.com/questions/14572412/how-to-open-a-popup-window-via-firefox-addon-contextual-menu");' +
'});'
});
This code would open up a new window (or tab) when the user clicks on the Open Window item. The window.open
function works in this context but I'm not sure what context you're not seeing it work in.
Hope this helps you.
Upvotes: 4