1
我在Firefox附加组件开发中遇到了麻烦。Firefox附加组件 - 如何在附加面板上的页面上获取张贴消息
[症状]: 无法接收来自Firefox附加栏的面板页面的消息,该消息是从panel.html中的iframe发送的。
这里是我的代码:
/*文件[popup.html] */ //体内我添加iframe元素。
iframe src="http://localhost/hello.html"
/*在文件[popup.js] */ //我添加侦听
window.addEventListener("message",
function(event) {
console.log("popupJS Receive Event from WebPage(" + event.origin);
console.log(event);
//alert(event);
});
/*在远程页面hello.html的*/ //点击发送消息。 强调文本
window.postMessage({ type: "FROM_PAGE", text: "Hello from the webpage!" }, "http://dicrectpass.com");
===== >> 但是,我仍然无法从IFRAME收到消息! 为什么?