【发布时间】:2018-01-13 22:54:24
【问题描述】:
我正在开发插件 chrome 和 firefox。
我的问题只出现在 Firefox 上,而不出现在 chrome 上。
我想在 domain2.com 的选项卡中创建一个带有 url domain1.com 的 XMLHttpRequest(不在后台脚本中)
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function(event) {
if (this.readyState === XMLHttpRequest.DONE) {
if (this.status === 200) {
console.log("Answer: %s", this.responseText);
} else {
console.log("Answer status: %d (%s)", this.status, this.statusText);
}
}
};
xmlHttp.open("GET", theUrl, true);
xmlHttp.send(null);
在 chrome 中我得到 200
但 Firefox 不执行请求(应答状态:0 ())
如果我将 domain1.com 替换为 domain2.com,它就在 firefox 上运行
在我的 content_scripts 匹配中,我添加了 domain1.com 和 domain2.com
感谢您的帮助!
【问题讨论】:
标签: javascript firefox xmlhttprequest firefox-addon firefox-addon-sdk