当对 https url 进行 ajax 调用时,我收到 net::ERR_INSECURE_RESPONSE 。 当我在浏览器中打开该 https 网址并接受证书时,我没有收到该错误。 但我不想在浏览器中打开该网址,并希望我的 JavaScript 捕获错误 net::ERR_INSECURE_RESPONSE。
我发现一个链接(即 How to handle ERR_INSECURE_RESPONSE in Google Chrome extension )实际上不起作用。
如果有人指导我如何以编程方式处理此错误,我将非常感激。在谷歌中进行了所有可能的搜索,但没有运气。
最佳答案
我认为您正在使用内容脚本。但Content脚本不能使用所有chrome API。
However, content scripts have some limitations. They cannot:
- Use chrome.* APIs, with the exception of:
- extension (getURL , inIncognitoContext , lastError , onRequest , sendRequest)
- i18n
- runtime (connect , getManifest , getURL , id , onConnect , onMessage , sendMessage)
- storage
- Use variables or functions defined by their extension's pages
- Use variables or functions defined by web pages or by other content scripts
因此您无法在内容脚本中使用 chrome.webRequest
API。与所有其他 Chrome API 一样,除了前面列出的 4 个之外,chrome.webReqest
也是未定义的。
关于javascript - 如何以编程方式处理 net::ERR_INSECURE_RESPONSE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32764619/