最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Chrome "Launched External Handler" console statement with mailto link - Stack Overflow

matteradmin4PV0评论

I've noticed this line in console.log in Chrome recently and it has me thinking that I'm doing something wrong when programmatically launching a mailto: link.

The line appears to be invoked from the Chromium source code from the external_protocol_handler file at /+/master/chrome/browser/external_protocol/external_protocol_handler

And the specific code triggering the console statement is:

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

The function name url.possibly_invalid_spec() has me questioning.

All I'm doing is using JavaScript to open a mailto: link from a https:// website (if that has anything to do with it) window.location.href = 'mailto:[email protected]';

Anyone heard of this? Is it new?

I've noticed this line in console.log in Chrome recently and it has me thinking that I'm doing something wrong when programmatically launching a mailto: link.

The line appears to be invoked from the Chromium source code from the external_protocol_handler file at https://chromium.googlesource./chromium/src/+/master/chrome/browser/external_protocol/external_protocol_handler

And the specific code triggering the console statement is:

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

The function name url.possibly_invalid_spec() has me questioning.

All I'm doing is using JavaScript to open a mailto: link from a https:// website (if that has anything to do with it) window.location.href = 'mailto:[email protected]';

Anyone heard of this? Is it new?

Share Improve this question asked Oct 6, 2020 at 19:47 MarcMarc 1,7702 gold badges18 silver badges26 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

Looking at git blame, we see that logger was added on June 24, 2020 by Eric Lawrence as part of the fix for bug 1096610 with the following explanation:

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.

With that in mind, one can conclude it's ok to have in DevTools console since it's just a notification that a browser is about to try and handle a link with an external protocol other than http/https (for example, mailto, ftp, etc).

Post a comment

comment list (0)

  1. No comments so far