我有覆蓋overlay.xul
覆蓋browser.xul
的文件。我想以類似於Chrome擴展中實現的方式實現消息傳遞。如何在Firefox擴展中實現消息傳遞?
chrome.manifest-
content helloworld content/
overlay chrome://browser/content/browser.xul chrome://helloworld/content/overlay.xul
overlay chrome://navigator/content/navigator.xul chrome://helloworld/content/overlay.xul
skin helloworld classic/1.0 skin/
style chrome://global/content/customizeToolbar.xul chrome://helloworld/content/overlay.css
如何我註冊content_script.js
這在我的情況是overlay.js
?
Overlay.xul -
<script type="application/x-javascript" src="chrome://helloworld/content/jquery.js" />
<script type="application/x-javascript" src="chrome://helloworld/content/overlay.js" />
<script type="application/x-javascript" src="chrome://helloworld/content/background.js" />
現在我overlay.js
我使用內 -
document.documentElement.addEventListener('click', function(e) {
messageManager.sendAsyncMessage('MyMessenger.MyMessage', {});
}, true);
而且background.js
是 -
addMessageListener("MyMessenger.MyMessage", function(obj) {
Firebug.Console.log(obj.name);
}, true);
- 什麼是正確的語法消息傳遞?
- 如何配置內容腳本和瀏覽器腳本之間的連接?