Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7405817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:27:42+00:00 2026-05-29T05:27:42+00:00

I have a simple addon that adds a button to toolbar. I want this

  • 0

I have a simple addon that adds a button to toolbar.

I want this toolbar to open a tab that shows a local html page that uses javascript to fetch some urls, process data and then display things on screen based on that data. I want this to happen on usual browser tab, not some extension window.

I want the extension to be portable on multiple platforms (by using html file and javascript) so I want just to have a tab with the html page that accesses javascript file on the same directory.

I use this on my button that opens the tab:

var win = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
  .getInterface(Components.interfaces.nsIWebNavigation)
  .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
  .rootTreeItem
  .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
  .getInterface(Components.interfaces.nsIDOMWindow);

var tab = win.gBrowser.addTab();
win.gBrowser.selectedTab = tab;

What should I add after this to show a local, extension packaged (I have no idea where to package it) html page that will access a separate javascript file.

(this might be a very simple question but mozilla documentation is a gigantic mess with old information that doesn’t work.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:27:43+00:00Added an answer on May 29, 2026 at 5:27 am

    First of all, your fancy tricks with nsIInterfaceRequestor seem to be unnecessary – it’s a very complicated way of writing:

    var win = window;
    

    What you wrote there is necessary to get from a content page to the browser window – normal window.top won’t work because of a security boundary between content and chrome. But your button already is in the browser window.

    Since you already have a button – you must be using an overlay meaning that you registered a chrome:// namespace. To open your page you can use loadOneTab method (this has the advantage that you don’t need to select the tab explicitly):

    window.gBrowser.loadOneTab("chrome://myextension/content/page.html", {inBackground: false});
    

    Of course you should change myextension here, it should be your chrome namespace. page.html should be put into the same directory where you have your overlay (typically chrome/content/). You can just use the regular script tag to load JavaScript files located in the same directory:

    <script type="text/javascript" src="script.js"></script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

NOTE: This is the simple version of my previous question that SHOULD have been
I have simple win service, that executes few tasks periodically. How should I pass
I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
I have simple WinForms application where modifying Windows Registry. The problem is that in
I have an existing Silverlight 3 app that I want to add Live Mesh
I have built a simple word addin that interacts with a company intranet. For
I have created a HTML document with following code.. <html> <head> <title>My Page</title> </head>
I have wrote a simple client that use TcpClient in dotnet to communicate. In
I have been looking round for an open-source CMS framework that I can use
I want to develop an addon with the addon builder. I read that with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.