开发者

Displaying extension page in browser tab

I'm trying to write extension that have some advanced control (much more than selecting from list or check/unchenck).

I wish to create separate page to do all required actions, idealy it would be separate tab.

The question is:

Is it possible to create XUL window and insert them into browser tab?

For now i got just one idea - store html page into /content folder, and use them. But i don't lik开发者_开发知识库e that user will see some wierd url chrome://blalbla/content/control.html etc.


That works with XUL pages too. But if you want to hide the chrome: URL from the user, you can create a component that redirects about:myext to the chrome: URL. A partial snippet follows:

myAbout.prototype = {
  QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIAboutModule]),

  getURIFlags: function(aURI) {
    return Components.interfaces.nsIAboutModule.ALLOW_SCRIPT;
  },

  newChannel: function(aURI) {
    var channel = ioSvc.newChannel("chrome://myext/content/myext.xul", null, null);
    channel.originalURI = aURI;
    return channel;
  }
};

You then have to register your component using the contract ID @mozilla.org/network/protocol/about;1?what=myext and this will redirect about:myext to your XUL page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜