将消息从web_accessible_resource发布到ContentScript

时间:2016-04-06 10:42:37

标签: google-chrome-extension postmessage

我试图将 .thumbnail2 { position: relative; float: left; z-index: 50; } .thumbnail2:hover span { visibility: hidden; } .thumbnail2 span { position: absolute; padding: 5px; visibility: hidden; text-decoration: none; } .thumbnail2 span img { border-width: 0px; } .thumbnail2:hover span { visibility: visible; width: 800px; height: 800px; top: 60px; left: 60px; } 文件中的邮件(实际上是一个附有JS的HTML文件)发送到Web Accessible Resource;但是事件监听器工作不正常..!

app.js:

ContentScript

contentscript.js

window.postMessage({myName: 'Sagar'}, '*');

的manifest.json

window.addEventListener("message", function(request) { 
//My Code 
}, true);

Tracker.html中引用了"content_scripts": [ { "js": ["jquery-1.11.3.min.js", "content-script.js"] } ], "web_accessible_resources": ["Tracker.html"] ..

我哪里错了?

window.postMessage from web_accessible_resource to content script的帖子,似乎无法正常工作.. !!!

0 个答案:

没有答案