我的问题很简单,我试图创建一个称为NaCl模块的chrome扩展.我的按钮和不同的文件似乎没问题,我在C++中非常简单的代码返回一个PostMessage hello World.但是,当我尝试它时,它不起作用.在Chrome扩展程序中包含NaCl模块,我还没有做过具体的事情吗?我必须说我有点失去希望.
这是我的"background.html":
<body>
<script src="background.js"></script>
<div id="listener">
<embed name="nacl_module"
id="nacl_correction"
src="nacl_correction.nmf"
type="application/x-nacl" />
</div>
<script >
document.getElementById('listener').addEventListener('load', moduleDidLoad, true);
</script>
</body>
Run Code Online (Sandbox Code Playgroud)
这是我的"background.js":
var NaclCorrectionModule = null; // Global application object.
function moduleDidLoad() {
NaclCorrectionModule = document.getElementById('nacl_correction');
//alert( NaclCorrectionModule);
if (NaclCorrectionModule == null) {
alert('Out');
}
else {
alert (NaclCorrectionModule);
}
NaclCorrectionModule.addEventListener('message', handleMessage, false);
}
function handleMessage(message_event) {
alert(message_event.data);
}
chrome.browserAction.onClicked.addListener(moduleDidLoad);
Run Code Online (Sandbox Code Playgroud)
最后,我的"Manifest.json":
{
"name": "Correction de Cordial sous Chrome",
"version": "1.0",
"background_page" :"background.html",
"description": "Intégration d'une extension Cordial pour …Run Code Online (Sandbox Code Playgroud)