registerProtocolHandler() lets websites register their
ability to open or handle particular URL schemes (aka protocols).
For example, this API lets webmail sites open
mailto: URLs, or VoIP sites open
Note: The original implementation required three
navigator.registerProtocolHandler(scheme, url, title),
which most browsers still support (see the compatibility table below). It is recommended to
still set the title, since browsers that support the updated spec will most likely be
backwards-compatible and still accept the title (but not use it).
A string containing the protocol the site wishes to handle. For example, you can register to handle SMS text message links by passing the
A string containing the URL of the handler. This URL must include
%s, as a placeholder that will be replaced with the escaped URL to be handled.
Note: The handler URL must use the
httpsscheme. Older browsers also supported
A human-readable title string for the handler. This will be displayed to the user, such as prompting “Allow this site to handle [scheme] links?” or listing registered handlers in the browser’s settings.
Note: The title has been removed from the spec due to spoofing concerns, but some browsers still require it (check the compatibility table below). It is recommended to always set the title, since browsers that support the updated spec most likely will be backwards-compatible and still accept the title (but not use it).
The user agent blocked the registration. This might happen if:
The registered scheme (protocol) is invalid, such as a scheme the browser handles
- The handler URL’s origin does not match the origin of the page calling this API.
- The browser requires that this function is called from a secure context.
- The browser requires that the handler's URL be over HTTPS.
%splaceholder is missing from the handler URL.
For security reasons,
registerProtocolHandler() restricts which schemes
can be registered.
A custom scheme may be registered as long as:
- The custom scheme's name begins with
The custom scheme's name includes at least 1 letter after the
- The custom scheme has only lowercase ASCII letters in its name.
web+burger, as shown in the Example below.
Otherwise, the scheme must be one of the following:
If your site is
burgers.example.com, you can register a protocol handler
for it to handle
web+burger: links, like so:
navigator.registerProtocolHandler("web+burger", "https://burgers.example.com/?burger=%s", "Burger handler"); // last title arg included for compatibility
This creates a handler that lets
web+burger: links send the user to your
site, inserting the accessed burger URL into the
This script must be run from the same origin as the handler URL (so any page at
https://burgers.example.com), and the handler URL must be
The user will be notified that your code asked to register the protocol handler, so
that they can decide whether or not to allow it. See the screenshot below for an example
|HTML Standard (HTML)|
BCD tables only load in the browser