title: Injecting DIV-Tag at top of page AND Automatic start of script when page is loading?
body: <p>I started to program my own Chrome extension today and I'm stuck since hours with one problem.
  Right now, I'm sending the current URL from the open website to my server where it's checked against some criterias and then a return value is sent back to the extension. This is working so far. I'm using only a popup.html, no background page.
  The request is only sent when the user clicks on the icon in the browser.
  How can I realize that the request is automatically sent, when the page is loaded?</p>
  
  <p>If there is a specific return value from the server the user should be given an unannoying warning. Alert boxes and new windows are...well...annoying. Best way should be the little popup under the icon of the extension but that's not possible without a user's click. So I thought of a little -layer at the top of the page.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  
  &lt;script&gt;
  window.addEventListener("load", sendRequest, false);  
  function sendRequest() {
  var q = "test";
  xmlHttp=new XMLHttpRequest();
  xmlHttp.open('GET', 'http://www.testurl.com/check.php?q='+q, true); 
  xmlHttp.onreadystatechange = function() {
      if (xmlHttp.readyState == 4) {
      document.getElementById("textf").innerText = xmlHttp.responseText;
      chrome.tabs.executeScript(null,{code:"&lt;div style='position: absolute; top: 0; left: 0; background-color=blue;layer-background-color: blue;'&gt;&lt;p&gt;test &lt;/p&gt;&lt;p&gt;test2 &lt;/p&gt;&lt;/div&gt;"});
  }
    }
  xmlHttp.send(null); 
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  //Just for the popup...
  &lt;font color="blue"&gt;&lt;p id="textf"&gt;Checking...&lt;/p&gt;&lt;/font&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>If I do </p>
  
  <pre><code>chrome.tabs.executeScript(null,{code:"alert('testalert')"});
  </code></pre>
  
  <p>it gives me the alert. However, the  isn't working and I can't figure out why :(</p>
  
  <p>Do I need a background page for all this since I only want to check the URL when the page is loaded?
  Why is the -thing not working but the alert is?</p>
  
  <p>Thank you in advance!</p>