javascript - How do I pass parameter to a `chrome.tabs.executeScript` in a chrome extension? -
this question has answer here: pass parameter content script injected using chrome.tabs.executescript() 2 answers when i'm getting message popup want execute script, simply: chrome.runtime.onmessage.addlistener(function(message, sender, response) { chrome.tabs.executescript({file: "content.js"}); }); my problem: content.js needs data message . how pass it? try chrome.runtime.onmessage.addlistener(function(message, sender, response) { chrome.tabs.executescript({code: paramname=paramvalue},function() { chrome.tabs.executescript({file: "content.js"}); }); }); they both injected same isolated world, content.js can refer same variables.