Javascript 无法从chrome扩展内容脚本访问本地主机
我正在尝试使用chrome扩展从iis上托管的Web应用程序发出警报。我的内容脚本代码如下Javascript 无法从chrome扩展内容脚本访问本地主机,javascript,asp.net-mvc,iis,google-chrome-extension,Javascript,Asp.net Mvc,Iis,Google Chrome Extension,我正在尝试使用chrome扩展从iis上托管的Web应用程序发出警报。我的内容脚本代码如下 chrome.runtime.onMessage.addListener( function (request, sender, sendResponse) { var results = ''; $.each(request, function (key, value) { results += key + ": " + value + '\n'; }); alert(res
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
var results = '';
$.each(request, function (key, value) {
results += key + ": " + value + '\n';
});
alert(results);
});
此web应用程序也托管在远程服务器中。该警报在远程服务器上的网页上运行良好,但在我的本地主机上不会发出警报。下面是清单文件的一个片段
"content_scripts": [
{
"matches": ["http://localhost/WebApp/*","http://staging.mysite.com/WebApp/*"],
"js": ["libs/jquery-1.11.3.min.js", "results.js"]
}
],
我遗漏了什么吗?我怀疑你能在本地主机上匹配你能匹配
localhost
。可能还有其他问题。使用调试器、简化代码等,或者将整个扩展zip链接到此处进行测试。我的扩展无法在http://localhost:8080/test.html
而我的权限中有http://*/*
,因此@ZigMandel似乎是正确的。我怀疑您能否在localhost上匹配您能否匹配localhost
。可能还有其他问题。使用调试器、简化代码等,或者将整个扩展zip链接到此处进行测试。我的扩展无法在http://localhost:8080/test.html
我的权限中有http://*/*
,因此@ZigMandel似乎是正确的。