سؤال

I want to detect first loading of NPAPI plugin/extension. Which event should i handle in extension/plugin.

هل كانت مفيدة؟

المحلول

I found the solution.

My requirement is i want inform the NPAPI plugin when browser starts.I am having my extension and NPAPI plugin.

Chrome Solution:

For chrome background_helper.js loads only once when new instance of chrome gets started. It will not reload on new page or new window.

Firefox solution: On Firefox window.load gets called when new windows gets opened so i have added code in window.load event handler as follows.

var Application = Components.classes["@mozilla.org/fuel/application;1"].getService(Components.interfaces.fuelIApplication);

var myExt= {
  onLoad: function() {
    var windowsArray = Application.windows;
    if(windowsArray.length == 1 && gBrowser.browsers.length == 1)
    {
       alert('FireFox started');
    }
  },
};

window.addEventListener('load', myExt.onLoad, false);

Here gBrowser is golbal object gBrowser.browsers.length wil give tab count.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top