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

  • Home
  • SEARCH
  • 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 5934125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:04:12+00:00 2026-05-22T15:04:12+00:00

I was looking for an event that is able to run some code after

  • 0

I was looking for an event that is able to run some code after clicking (changing) tab in browser, but I haven’t found it.

Is it possible to achieve this event somehow?

I’m already listening to DOMContentLoaded event, I’m displaying some information about the current page on the status bar. When I changed tab, the information in the status bar is not correct (I have to reload the page).

thank you

  • 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-22T15:04:13+00:00Added an answer on May 22, 2026 at 3:04 pm

    There are two possible ways to do this.

    Detecting location change

    The nsIWebProgressListener interface is used to detect when the window’s location has changed. Place something like this in your window’s onLoad handler:

    // implements nsIWebProgressListener
    var listener = {
        onLocationChange: function(aProgress, aRequest, aURI) {
            // fires on tab change; update status here;
            // get the currently selected tab
            var currDoc = gBrowser.contentDocument; 
        },
        onStateChange: function(a, b, c, d) {},
        onProgressChange: function(a, b, c, d, e, f) {},
        onStatusChange: function(a, b, c, d) {},
        onSecurityChange: function(a, b, c) {}
    }
    
    gBrowser.addProgressListener(
        listener, 
        Components.interfaces.nsIWebProgress.NOTIFY_LOCATION);
    

    Note that onLocationChange fires every time the window’s location changes. This means that it fires when the browser is started, when a new URL is loaded in the current tab, when the tab changes, etc. This is probably what you want if your goal is to update the status bar based on the currenty-loaded URL.

    Detecting tab change

    To detect only the case when a new tab has been selected, use the TabSelect event. Full example copied from here:

    function exampleTabSelected(event) {
      var browser = gBrowser.selectedBrowser;
      // browser is the XUL element of the browser that's just been selected
    }
    
    // During initialisation
    var container = gBrowser.tabContainer;
    container.addEventListener("TabSelect", exampleTabSelected, false);
    
    // When no longer needed
    container.removeEventListener("TabSelect", exampleTabSelected, false);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking to log unhandled javascript exceptions. Is there an event that fires when
I am looking for things like reordering of code that could even break the
What I'm looking for is an IDE that will run on Linux, that has
I am looking for a version of Scheme or even LISP that I can
I am currently looking at the unload event of a window to try to
How do you invoke a tkinter event from a separate object? I'm looking for
Hey, I stumbled upon this site looking for solutions for event overlaps in mySQL
Looking for feedback on : http://code.google.com/p/google-perftools/wiki/GooglePerformanceTools
Looking for an example that: Launches an EXE Waits for the EXE to finish.
My dev box is a Windows 7 (x64) machine. I've got some code (C#,

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.