My content script requests two strings from background.html:
var subject = document.getElementById("subject");
var body = document.getElementById("body");
chrome.extension.sendRequest({name: "domain"},
function(response)
{
subject.setAttribute("value", response.domain + ": ");
});
chrome.extension.sendRequest({name: "url"},
function(response)
{
body.defaultValue = "URL of last page visited: " + response.url;
});
background.html earlier had saved the data to local storage:
localStorage["domain"] = site;
localStorage["url"] = tab.url;
and waits for the requests from the content script:
//Wait for request for the site value and URL from content script
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse)
{
sendResponse({domain: localStorage["domain"]});
});
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse)
{
sendResponse({domain: localStorage["url"]});
});
For some reason, the content script receives the "domain" value OK,
but displays "undefined" for the "url" value. TIA.
--
You received this message because you are subscribed to the Google Groups
"Chromium-extensions" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/chromium-extensions?hl=en.