Question

I am working on a simple firefox extension. I am stuck with an issue in which i need some help.

I want to add a style attribute in form element whenever page is loaded completely, so i am first trying with a simple alert.

So, i wrote some javascript code like,

var secureSession = function () {
    var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
    return {
        init : function () {
            gBrowser.addEventListener("load", function () {
                var autoRun = prefManager.getBoolPref("extensions.securesession.autorun");
                if (autoRun) {
                    alert("Hello World");
                }
            }, false);
        },
   };
}();

window.addEventListener("load", secureSession.init, false);

I set autorun -> ON, in preferences,

Now, the problem is it's not showing alert by default. means on page load.

It only showing me alert whenever i right click and click on inspect element.

Anyone has any idea about this.

Any help will be appreciated.

Was it helpful?

Solution

try gBrowser.addEventListener("DOMContentLoaded"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top