开发者

Firefox Extension Development: load function triggered more than once

I am new to Firefox extension development.

I have started to work on an extension that triggers when the page has been loaded. The problem I have is that the event is triggered twice. Its almost as if two threads are created when the users navigates or browses web sites.

Why does this happen and how could this be ch开发者_如何学Pythonanged to only trigger once.

I have attached the files.

Here is the browser.xul file

<!DOCTYPE DOMDropper SYSTEM "chrome://DOMDropper/locale/translations.dtd">
<overlay id="sample" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
        <script src="blah.js" />    
</overlay>

Here is blah.js

var Blah = function () {

return {
    init : function () {            
        gBrowser.addEventListener("load", function () {         
            Blah.run();         
        }, false);          
    },  

    run : function () {
        alert("Trigger!");
    }
};
}();
window.addEventListener("load", Blah.init, false);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜