【发布时间】:2013-02-23 13:21:36
【问题描述】:
我在开发 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 的消息! 为什么?
【问题讨论】:
标签: javascript html firefox firefox-addon