title: Firefox XUL Extension Calls Function in Injected Script?
body: <p>Two part question:</p>
  
  <p>1) How do you inject a script (for example 'library.js') to the HTML DOM when making an XUL extension?</p>
  
  <p>2) I currently have a toolbar button which I want to call a function in 'library.js' when the button is clicked.</p>
  
  <p>Here is my current XUL for the toolbar button</p>
  
  <pre><code>&lt;toolbarpalette id="BrowserToolbarPalette"&gt;
    &lt;toolbarbutton id="myextension-button" 
      class="toolbarbutton-1"
      image="chrome://xulschoolhello/skin/favicon.png"
        oncommand="doStuff();"
      label="label" tooltiptext="tooltip" /&gt;
  &lt;/toolbarpalette&gt;
  </code></pre>
  
  <p>Here is library.js (which will be injected into the DOM). Library.js will have a bunch of functions modifying the DOM. Here is one example:</p>
  
  <pre><code>function changeTheDOM(){
       document.body.innerHTML = 'I changed it';
  }
  </code></pre>
  
  <p>I want doStuff() to somehow call the function changeTheDOM(), which is in the HTML DOM. Let me know if that makes sense. </p>
  
  <p>With all these different namespaces/context, its very difficult for me as a beginner to grasp how to interact between my application code and the DOM.</p>