Google chrome extension 将消息从web\u可访问的\u资源发布到ContentScript
我正试图将我的Google chrome extension 将消息从web\u可访问的\u资源发布到ContentScript,google-chrome-extension,postmessage,Google Chrome Extension,Postmessage,我正试图将我的网络可访问资源文件(实际上是一个HTML文件,附带了一个JS)中的消息发布到ContentScript;但是事件侦听器工作不正常 app.js: window.postMessage({myName: 'Sagar'}, '*'); contentscript.js window.addEventListener("message", function(request) { //My Code }, true); manifest.json "content_scripts
网络可访问资源
文件(实际上是一个HTML文件,附带了一个JS)中的消息发布到ContentScript
;但是事件侦听器工作不正常
app.js:
window.postMessage({myName: 'Sagar'}, '*');
contentscript.js
window.addEventListener("message", function(request) {
//My Code
}, true);
manifest.json
"content_scripts": [
{
"js": ["jquery-1.11.3.min.js", "content-script.js"]
}
],
"web_accessible_resources": ["Tracker.html"]
Tracker.html中引用了app.js
我哪里做错了
有一个帖子结束了,它似乎不起作用了 你能提供更多的代码吗?就像整个清单文件一样,在哪里使用Tracker.html?