title: Chrome Extension script won't execute after injection
body: <p>I researched this here at StackOverflow and either I did not come across the answer or I didn't understand the answer.</p>
  
  <p>I am injecting a script that will toggle the header on a piece of cloud software. Trying to free up some screen real estate. </p>
  
  <p>When I try to execute my script by clicking on the button, I get the following error:</p>
  
  <pre><code>Uncaught ReferenceError: toggle is not defined
  at HTMLInputElement.onclick 
  </code></pre>
  
  <p>Which is odd since I define toggle just above the button. When I hard code the script into the page (as a saved HTML file)</p>
  
  <p>Here are my files starting with the </p>
  
  <p><strong>manifest.json</strong></p>
  
  <pre><code>    {
    "name": "Injector",
    "version": "0.0.1",
    "manifest_version": 2,
    "description": "Injecting stuff",
    "homepage_url": "http://verdevalley.ihostfull.com",
    "background": {
      "scripts": [
        "background.js"
      ],
      "persistent": true
    },
    "browser_action": {
      "default_title": "Inject!"
    },
      "web_accessible_resources": ["script.js"],
    "permissions": [
      "https://*/*",
      "http://*/*",
      "file://*",
      "activeTab",
      "tabs"
    ]
  }
  </code></pre>
  
  <p><strong>background.js</strong></p>
  
  <pre><code>// listen for our browerAction to be clicked
  chrome.browserAction.onClicked.addListener(function (tab) {
      // for the current tab, inject the "inject.js" file &amp; execute it
      chrome.tabs.executeScript(tab.ib, {
          file: 'inject.js'
      });
  });
  </code></pre>
  
  <p><strong>inject.js</strong></p>
  
  <pre><code>(function() {
  var div = document.createElement('div');
  div.style.position = 'fixed';
  div.style.zIndex="1004";
  div.innerHTML = '&lt;script id="custom"&gt;function toggle(){let x = document.getElementById("fixedTop");if (x.style.display === "none") {x.style.display = "block";} else {x.style.display = "none";}}&lt;/script&gt;&lt;input type=button value=toggle onclick=toggle  float="left"&gt;';
  document.body.appendChild(div);
  document.getElementById('navbar').appendChild(div);
  
  })();
  </code></pre>
  
  <p>If needed I can provide an HTML file on which to run this script, but I have a feeling it won't be necessary.</p>