从firefox侧边栏监视所选选项卡中的页面加载事件



当主内容窗口中的选定选项卡被重新加载或更改时,我希望能够在firefox侧边栏js文件中运行一个函数。因此侧边栏可以根据用户正在查看的网站进行更改

有人能给我指正确的方向吗?

我的解决方案从某处被盗,但不记得在哪里:

//add the load eventListener to the window object
window.addEventListener("load", function() { functioname.init(); }, true);

var functionname =  { 
    //add the listener for the document load event
init: function() {
    var appcontent = document.getElementById("appcontent");   // browser
    if(appcontent)
        appcontent.addEventListener("DOMContentLoaded", functionname.onPageLoad, false);
    },
    //function called on document load
    onPageLoad: function(aEvent) {
        if(aEvent.originalTarget.nodeName == "#document"){
        }
     }
}

@oly1234-你的回答帮助我找到了来源:
Mozilla开发者中心-页面加载

(https://developer.mozilla.org/en/Code_snippets/On_page_load)

最新更新