javascript - 如何以编程方式处理 net::ERR_INSECURE_RESPONSE

标签 javascript google-chrome google-chrome-extension ssl-certificate general-network-error

当对 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:

  1. Use chrome.* APIs, with the exception of:
    • extension (getURL , inIncognitoContext , lastError , onRequest , sendRequest)
    • i18n
    • runtime (connect , getManifest , getURL , id , onConnect , onMessage , sendMessage)
    • storage
  2. Use variables or functions defined by their extension's pages
  3. Use variables or functions defined by web pages or by other content scripts

因此您无法在内容脚本中使用 chrome.webRequest API。与所有其他 Chrome API 一样,除了前面列出的 4 个之外,chrome.webReqest 也是未定义的。

More information in Chrome Documentation

关于javascript - 如何以编程方式处理 net::ERR_INSECURE_RESPONSE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32764619/

相关文章:

javascript - AngularJS 服务变量引用

javascript - JS Loop 不会循环,直到我注释掉我的 switch 方法

javascript - 用户点击电子邮件中的链接,打开电子邮件客户端,如何关闭窗口/标签?

javascript - 无法在react-bootstrap中调用Carousel函数

javascript - 识别 JavaScript 中回调 (JSON) 函数的调用者(或如何传递参数)

javascript - Chrome webRequest 响应正文 (POST) 错误

javascript - 我可以使用 brython 开发 Chrome 扩展吗?

html - 从谷歌浏览器编辑 HTML

Javascript变量范围混淆

javascript - 努力在 Chrome 扩展中获取 DOM 数据