javascript - 带有 mailto 链接的 Chrome "Launched External Handler"控制台语句

标签 javascript google-chrome

我最近在 Chrome 的 console.log 中注意到了这一行,这让我觉得我在以编程方式启动 mailto: 链接时做错了什么。

该行似乎是从位于 https://chromium.googlesource.com/chromium/src/+/master/chrome/browser/external_protocol/external_protocol_handler.ccexternal_protocol_handler.cc 文件的 Chromium 源代码中调用的

而触发控制台语句的具体代码是:

web_contents->GetMainFrame()->AddMessageToConsole(
      blink::mojom::ConsoleMessageLevel::kInfo,
      "Launched external handler for '" + url.possibly_invalid_spec() + "'.");

函数名称 url.possibly_invalid_spec() 让我产生疑问。

我所做的就是使用 JavaScript 打开来自 https:// 网站的 mailto: 链接(如果与它有任何关系的话)window.location.href = 'mailto:me@website.com';

有人听说过这个吗?是新的吗?

enter image description here

最佳答案

查看git blame ,我们看到 Eric Lawrence 于 2020 年 6 月 24 日将记录器添加为 the fix 的一部分对于 bug 1096610,解释如下:

Log external handler invocations to the console.

Previously, failing to invoke an external protocol handler ('foo://bar') would fail silently if the protocol was not registered or if the user gesture requirement was not met. This limitation made it difficult for web developers to troubleshoot such situations. This CL emits errors to the Developer Tools console when the protocol handler is not registered, is forbidden, or is temporarily blocked pending a user-gesture. Similarly, if an external handler is launched, an informational log entry is added.

考虑到这一点,可以得出结论,在 DevTools 控制台中使用它是可以的,因为它只是一个通知,表明浏览器将尝试处理与 http/https 以外的外部协议(protocol)的链接(例如,mailtoftp 等)。

关于javascript - 带有 mailto 链接的 Chrome "Launched External Handler"控制台语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64232834/

相关文章:

google-chrome - 通过 Selenium Java 使用 ChromeDriver 和 Chrome v80 从渲染器接收消息超时 : 0. 100 条日志消息

javascript - Chrome 中的网络推送通知

javascript - 如何在 Highcharts 同步图表中仅显示一个 x Axis 标签

javascript - 在javascript中获取声音长度(持续时间)

html - 将 HTML5 Web Speech API 输出保存到文件

css - 下拉菜单在 chrome 中不起作用

javascript - 下划线模板抛出变量未定义错误

javascript - 找到 div 后如何在 javascript/jquery 中设置 img 标签的样式?

javascript - 如何在nodeJS的forEach中正确使用async

google-chrome - wss 连接失败:连接建立时出错:net::ERR_CERT_COMMON_NAME_INVALID