使用javascript重定向到chrome扩展
我正在尝试使用以下HTML启动Chrome扩展:使用javascript重定向到chrome扩展,javascript,google-chrome,Javascript,Google Chrome,我正在尝试使用以下HTML启动Chrome扩展: <!DOCTYPE html> <html> <script> (function(){ var chromeId = 'theIdOfMyChromeExtension'; window.location.href = "chrome-extension://"+chromeId+"/main.html"; })(); <
<!DOCTYPE html>
<html>
<script>
(function(){
var chromeId = 'theIdOfMyChromeExtension';
window.location.href = "chrome-extension://"+chromeId+"/main.html";
})();
</script>
</html>
(功能(){
var chromeId='theIdOfMyChromeExtension';
window.location.href=“chrome扩展名:/”+chromeId+“/main.html”;
})();
如果我在Chrome中手动打开此文件,它将启动扩展名fine,但是如果此HTML是Web服务器上HTTP GET的响应,Chrome将重定向到about:blank
顺便说一句,如果我在Firefox中这样做,它显然会失败,但它至少会重定向到扩展URL
有什么我做得不对吗?更新 您也应该将此添加到您的清单中
"web_accessible_resources": ["main.html"],
将此添加到扩展清单中
"externally_connectable": {
"matches": ["*://*.speficifDomain.com/*"]
}
更新 您也应该将此添加到您的清单中
"web_accessible_resources": ["main.html"],
将此添加到扩展清单中
"externally_connectable": {
"matches": ["*://*.speficifDomain.com/*"]
}
穆罕默德,谢谢你的评论,但是它仍然不起作用。我需要先安排主持人还是做其他事情?穆罕默德,谢谢你的评论,但是它仍然不起作用。我需要先设置主机还是执行其他操作?请立即尝试,将路径放置到main.htmltry,将路径放置到main.html