protocol_handlers
Type | Array |
---|---|
Mandatory | No |
Example | "protocol_handlers": [ { "protocol": "ircs", "name": "IRC Mozilla Extension", "uriTemplate": "https://irccloud.mozilla.com/#!/%s" } ] |
Use this key to register one or more web-based protocol handlers.
A protocol handler is an application that knows how to handle particular types of links: for example, a mail client is a protocol handler for "mailto:" links. When the user clicks a "mailto:" link, the browser opens the application selected as the handler for the "mailto:" protocol (or offers them a choice of handlers, depending on their settings).
With this key, you can register a website as a handler for a particular protocol. The syntax and semantics of this key is very much like the Navigator.registerProtocolHandler()
function, except that with registerProtocolHandler()
a website can only register itself as a handler.
Each protocol handler has three properties, all mandatory:
protocol
-
A string defining the protocol. This must be either:
- one of the following: "bitcoin", "dat", "dweb", "ftp", "geo", "gopher", "im", "ipfs", "ipns", "irc", "ircs", "magnet", "mailto", "matrix", "mms", "news", "nntp", "sip", "sms", "smsto", "ssb", "ssh", "tel", "urn", "webcal", "wtai", "xmpp".
- a string consisting of a custom name prefixed with "web+" or "ext+". For example: "web+foo" or "ext+foo". The custom name must consist only of lower-case ASCII characters. It's recommended that extensions use the "ext+" form.
name
- A string representing the name of the protocol handler. This will be displayed to the user when they are being asked if they want this handler to open the link.
uriTemplate
- A string representing the URL of the handler. This string must include "%s" as a placeholder: this will be replaced with the escaped URL of the document to be handled. This URL might be a true URL, or it could be a phone number, email address, or so forth. This is a localizable property.
Example
"protocol_handlers": [ { "protocol": "magnet", "name": "Magnet Extension", "uriTemplate": "https://example.com/#!/%s" } ]
If the protocol is not in the allowed list then it has to start with 'ext+'
"protocol_handlers": [ { "protocol": "ext+foo", "name": "Foo Extension", "uriTemplate": "https://example.com/#!/%s" } ]
Handlers can also be extension pages.
"protocol_handlers": [ { "protocol": "magnet", "name": "Magnet Extension", "uriTemplate": "/example.xhtml#!/%s" } ]
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
protocol_handlers |
No |
No |
54 |
? |
No |
No |
? |
? |
54 |
? |
? |
? |
dat |
No |
No |
59 |
? |
No |
No |
? |
? |
59 |
? |
? |
? |
dweb |
No |
No |
59 |
? |
No |
No |
? |
? |
59 |
? |
? |
? |
ftp |
No |
No |
88 |
? |
No |
No |
? |
? |
88 |
? |
? |
? |
gopher |
No |
No |
56 |
? |
No |
No |
? |
? |
56 |
? |
? |
? |
ipfs |
No |
No |
59 |
? |
No |
No |
? |
? |
59 |
? |
? |
? |
ipns |
No |
No |
59 |
? |
No |
No |
? |
? |
59 |
? |
? |
? |
matrix |
No |
No |
90 |
? |
No |
No |
? |
? |
90 |
? |
? |
? |
ssb |
No |
No |
59 |
? |
No |
No |
? |
? |
59 |
? |
? |
? |
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/protocol_handlers