d'oh! I see the problem: the second onRequest should read sendResponse ({url: localStorage["url"]}). Thanks, Yoanis!
On Dec 27, 7:51 pm, FractalBob <ruom...@gmail.com> wrote: > 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 chromium-extensi...@googlegroups.com. To unsubscribe from this group, send email to chromium-extensions+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/chromium-extensions?hl=en.