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 6060771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:51:47+00:00 2026-05-23T08:51:47+00:00

I am currently developing a Firefox extension, and I need the ability to be

  • 0

I am currently developing a Firefox extension, and I need the ability to be able to differentiate between each open tab.

The idea is to be able to associate outgoing HTTP requests with its origin tab. For each ‘on-modify-request‘ event that is observed, for example, I would know that it came from tab #2, or tab #3.

This would have to be good enough to differentiate between multiple instances of the same website. Enumerating through all open tabs will not work if I have three ‘www.google.com’ tabs open for example.

As far as I know, tabbrowser objects in Mozilla do not have any unique identifiers or properties.

Any ideas?

  • 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-23T08:51:47+00:00Added an answer on May 23, 2026 at 8:51 am

    http-on-modify-request gives you the actual request object. From there you need to get the associated window, the way to go is nsILoadContext here. I use this code:

    function getRequestWindow(request)
    {
      try
      {
        if (request.notificationCallbacks)
          return request.notificationCallbacks
                        .getInterface(Components.interfaces.nsILoadContext)
                        .associatedWindow;
      } catch(e) {}
    
      try
      {
        if (request.loadGroup && request.loadGroup.notificationCallbacks)
          return request.loadGroup.notificationCallbacks
                                  .getInterface(Components.interfaces.nsILoadContext)
                                  .associatedWindow;
      } catch(e) {}
    
      return null;
    }
    

    That’s a content window (and probably even a frame). So you have to find the corresponding tab – use gBrowser.getBrowserForDocument(). Like this:

    var wnd = getRequestWindow(request);
    var browser = (wnd ? gBrowser.getBrowserForDocument(wnd.top.document) : null);
    

    Now you have the <browser> element that the request belongs to – if any. Because the request might also originate from the Firefox UI or a different browser window. You can set your own expando property on that element to get a tab identifier (choose a unique name to avoid conflicts with other extensions). Something like this:

    if (!("_myExtensionTabId" in browser))
        browser._myExtensionTabId = ++maxTabId;
    var tabId = browser._myExtensionTabId;
    

    Here maxTabId would be a global variable that’s initially zero. And “myExtension” would be ideally replaced by something unique to your extension (e.g. its name).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently developing a firefox extension which checks some server side XML-File on a
I am developing my first Firefox extension and for that I need to get
Currently developing a PHP framework and have ran into my first problem. I need
I am currently developing this site: tochat.vn As viewing in Firefox 7.0.1, it has
I'm currently developing a firefox plugin. This plugin has to handle very crappy website
I'm currently developing an addon for firefox that posts data periodically to a server;
I'm developing a Firefox extension which places a button in the status bar. When
I'm developing an asynchronous database searching tool. It currently works with firefox and chrome,
Currently developing an application using the newest version of symfony, obtained through PEAR. This
We are currently developing a server whereby a client requests interest in changes to

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.