title: Chrome Extensions: connect "Content Script" with injected DOM
body: <p>I realized we can work at shared DOM (<a href="http://code.google.com/chrome/extensions/content_scripts.html" rel="nofollow">according to manual</a>) from content scripts.</p>
  
  <p>We can connect injected DOM content with our Content Scripts via</p>
  
  <pre><code>element.addEventListener('click',function(){ ourController.fnCallback(); });
  // or
  element.onclick = ourController.fnCallback;
  </code></pre>
  
  <p>But when injected DOM implements something like this:</p>
  
  <pre><code>&lt;a href="javascript:ourController.fnCallback();"&gt;Click Me!&lt;/a&gt;
  </code></pre>
  
  <p>thrown error is <code>cannot call fnCallback() on undefined ourController</code> (not exactly rewritten error messages)</p>
  
  <p>Is there aby way we can communicate with our javascript object from injected dom like i tried in second example?</p>
  
  <p>Object is defined in <code>content_script.js</code> like this:</p>
  
  <pre><code>var ourController = {
      fnCallback: function(){
          // code here
      }
  };
  </code></pre>
  
  <p>and this code is placed directly in script loaded according to manifest like this:</p>
  
  <pre><code>"content_scripts": [ {
    "js": [ "content_script.js" ],
    "matches": [ "http://*/*", "https://*/*", "ftp://*/*" ],
    "run_at": "document_start"
  }],
  </code></pre>