For a Google Chrome extension, none of the Javascript I write to manipulate the DOM of the extension popup.html seems to have any effect on the popup's DOM. I can manipulate the DOM of the current webpage in the browser just fine by using content_script.js, and I'm interested in grabbing data from the webpage and outputting it into the extension popup, like so (below: popup.html):
<div id="extensionpopupcontent">Links</div>
<a onclick="click()">Some Link</a>
<script type="text/javascript">
function click() {
chrome.tabs.executeScript(null, {file: "content_script.js"});
document.getElementById("extensionpopupcontent").innerHTML = variableDefinedInContentScript;
window.close();
}
</script>
I tried using chrome.extension.sendRequest from the documentation at http://code.google.com/chrome/extensions/messaging.html, but I'm not sure how to properly use it in my case, specifically the greeting and the response.
contentscript.js
================
chrome.extension.sendRequest({greeting: "hello"}, function(response) {
console.log(response.farewell);
});