1

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.

Anyone able to point me in the right direction?

2 Answers 2

2

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"){
        }
     }
}
0

@oly1234 - your answer helped me to find the source:
Mozilla Developer Center - On page load

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.