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);
精彩评论