How to send xhr.responseXML object from background.html to contentscript.js
I want to send the object returned by the xhr.responseXML statement from the background.html file to the contentscript.js file in my google chrome开发者_运维百科 extension so that I will be able to access/mosify that object in the content script.
Is this possible? If yes, how?
Thanks in advance.. :-)
In background page:
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.sendRequest(tab.id, {greeting: "hello"});
});
in content script:
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
console.log("Received data:", request);
});
It is called message passing, you can read more about it here.
精彩评论