<p>I want to be able to run a function in my firefox sidebar js file when the selected tab in the main content window is reloaded or changed. So the sidebar can change depending on the site the user is looking at. </p>

<p>Anyone able to point me in the right direction?</p>

My solution pilfered from somewhere but can't remember where:
```
```
//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"){
        }
     }
}
```
```