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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:26:56+00:00 2026-05-22T16:26:56+00:00

This is something that is puzzling the heck out of me, my code: var

  • 0

This is something that is puzzling the heck out of me, my code:

        var this_version=null;              
        try 

    {


// Firefox 4 and later; Mozilla 2 and later
        Components.utils.import("resource://gre/modules/AddonManager.jsm");
        AddonManager.getAddonByID("Mf@mafiaafire.com", function(addon) {
           // alert("My extension's version is r" + addon.version);
           this_version = addon.version;
      });
    }
    catch (ex) {
        // Firefox 3.6 and before; Mozilla 1.9.2 and before
        var em = Components.classes["@mozilla.org/extensions/manager;1"]
                 .getService(Components.interfaces.nsIExtensionManager);
        var addon = em.getItemForID("Mf@mafiaafire.com");
        //alert("My extension's version is rr" + addon.version);
       this_version = addon.version;
    }
    alert("aa:"+this_version);

    /* #### End ### */


            if (prefManager.getCharPref("extensions.mafiaafire.quickfilter_ver") != this_version) 
                {



                    //prefManager.setCharPref("extensions.mafiaafire.quickfilter_ver",this.version);
                    alert("bb:"+this_version);
                    //gBrowser.selectedTab = gBrowser.addTab(prefManager.getCharPref("extensions.mafiaafire.quickfilter_ver_change_url"));    
                }

I am on FF 4, and the first alert is always giving me null and the second alert the correct version.

But if I take out the first alert, then the second alert is giving me null!!!!

It just does not make any sense.

  • 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-22T16:26:57+00:00Added an answer on May 22, 2026 at 4:26 pm

    The key is that the Firefox 4 code is asynchronous.

    AddonManager.getAddonByID("Mf@mafiaafire.com", function(addon) {
      // alert("My extension's version is r" + addon.version);
      this_version = addon.version;
    });
    

    means, go get the version of this addon, and when you get it, let me know by calling this function here. When you get to the first alert, the addon manager hasn’t gotten it yet. Since it takes a second or so before you click OK on the alert, it does have it by the time the second alert comes.

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

Sidebar

Related Questions

This is something that's I've wanted to know recently, mostly out of curiousity. I'm
This is just something that's been puzzling me ever since I read about iterators
This is something that I think would be very useful. Basically, I'd like there
This is something that I always find a bit hard to explain to others:
This is something that I have never fully grasped in .NET as to the
This is something that I have always wondered about, but never bothered to profile.
This is something that comes up so often I almost stopped thinking about it
This is something that made me doubt for a while so I thought it
This is something that's been bugging me for many years: why most online services
This is something that I don't see much discussed. I'm developing a software that

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.