For the Google Chrome extension, none of the Javascript that I write to control the DOM of the popup.html extension seems to affect the pop-up DOM. I can effectively manipulate the DOM of the current webpage in the browser using content_script.js, and I'm interested in capturing data from the webpage and displaying it in an extension popup window (for example: 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 use it correctly in my case, in particular the greeting and response.
contentscript.js
================
chrome.extension.sendRequest({greeting: "hello"}, function(response) {
console.log(response.farewell);
});