Skip to content

Commit

Permalink
Delete web-based protocol handler page; fold relevant content into AP…
Browse files Browse the repository at this point in the history
…I method page
  • Loading branch information
wbamberg committed Aug 7, 2024
1 parent d71da81 commit deae7f2
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 234 deletions.
3 changes: 2 additions & 1 deletion files/en-us/_redirects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7372,7 +7372,7 @@
/en-US/docs/Vuletube-vue-typescript-threejs-nui-voice-opencvjs /en-US/docs/Games/
/en-US/docs/WOFF /en-US/docs/Web/CSS/CSS_fonts/WOFF
/en-US/docs/We/API/RotationRate /en-US/docs/Web/API/DeviceMotionEvent/rotationRate
/en-US/docs/Web-based_protocol_handlers /en-US/docs/Web/API/Navigator/registerProtocolHandler/Web-based_protocol_handlers
/en-US/docs/Web-based_protocol_handlers /en-US/docs/Web/API/Navigator/registerProtocolHandler
/en-US/docs/Web-related_technologies /en-US/docs/Related
/en-US/docs/Web/API/AbortController/FetchController /en-US/docs/Web/API/AbortController/AbortController
/en-US/docs/Web/API/AbortSignal/abort /en-US/docs/Web/API/AbortSignal/abort_static
Expand Down Expand Up @@ -9103,6 +9103,7 @@
/en-US/docs/Web/API/Navigator/mediaDevices/enumerateDevices /en-US/docs/Web/API/MediaDevices/enumerateDevices
/en-US/docs/Web/API/Navigator/mediaDevices/getUserMedia /en-US/docs/Web/API/MediaDevices/getUserMedia
/en-US/docs/Web/API/Navigator/mozIsLocallyAvailable /en-US/docs/Web/API/Navigator
/en-US/docs/Web/API/Navigator/registerProtocolHandler/Web-based_protocol_handlers /en-US/docs/Web/API/Navigator/registerProtocolHandler
/en-US/docs/Web/API/NavigatorConcurrentHardware /en-US/docs/Web/API/Navigator
/en-US/docs/Web/API/NavigatorConcurrentHardware/hardwareConcurrency /en-US/docs/Web/API/Navigator/hardwareConcurrency
/en-US/docs/Web/API/NavigatorGeolocation /en-US/docs/Web/API/Geolocation
Expand Down
30 changes: 0 additions & 30 deletions files/en-us/_wikihistory.json
Original file line number Diff line number Diff line change
Expand Up @@ -48262,36 +48262,6 @@
"BenoitL"
]
},
"Web/API/Navigator/registerProtocolHandler/Web-based_protocol_handlers": {
"modified": "2019-03-24T00:11:06.750Z",
"contributors": [
"sundevour",
"chrisdavidmills",
"thgh",
"ObooChin",
"Jeremie",
"groovecoder",
"teoli",
"staktrace",
"ethertank",
"Skierpage",
"sebmozilla",
"Crash",
"tito",
"Brettz9",
"Chris Chittleborough",
"Sheppy",
"Dabear",
"Mgjbot",
"Varmaa",
"Potappo",
"Shamrin",
"Dmose",
"MarkFinkle",
"Mcaruso",
"Callek"
]
},
"Web/API/Navigator/requestMediaKeySystemAccess": {
"modified": "2020-10-15T21:34:19.510Z",
"contributors": [
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/mozilla/firefox/releases/3/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ If you're a developer trying to get a handle on all the new features in Firefox
- : Provides information about changes you may need to make to your website or web application to take advantage of new features in Firefox 3.
- [Online and offline events](/en-US/docs/Web/API/Navigator/onLine)
- : Firefox 3 supports WHATWG online and offline events, which let applications and extensions detect whether or not there's an active Internet connection, as well as to detect when the connection goes up and down.
- [Web-based protocol handlers](/en-US/docs/Web/API/Navigator/registerProtocolHandler/Web-based_protocol_handlers)
- [Web-based protocol handlers](/en-US/docs/Web/API/Navigator/registerProtocolHandler)
- : You can now register web applications as protocol handlers using the `navigator.registerProtocolHandler()` method.
- [Drawing text using a canvas](/en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_text)
- : You can now draw text in a canvas using a non-standardized API supported by Firefox 3.
Expand Down
118 changes: 55 additions & 63 deletions files/en-us/web/api/navigator/registerprotocolhandler/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ browser-compat: api.Navigator.registerProtocolHandler

{{APIRef("HTML DOM")}}{{securecontext_header}}

The **{{domxref("Navigator")}}** method **`registerProtocolHandler()`** lets websites register their ability to open or handle particular URL schemes (aka protocols).
The **{{domxref("Navigator")}}** method **`registerProtocolHandler()`** lets websites register their ability to open or handle particular URL schemes (also known as protocols).

For example, this API lets webmail sites open `mailto:` URLs, or VoIP sites open `tel:` URLs.

To register a protocol handler, a website calls `registerProtocolHandler()`, passing in the protocol to register and a template URL.

When the user activates a link that uses the registered protocol, the browser will insert the [`href`](/en-US/docs/Web/HTML/Element/a#href) from the activated link into the URL template supplied during handler registration, and navigate the current page to the resulting URL.

The browser may ask the user to confirm that they want the page to be allowed to handle the protocol, either when the protocol is registered or when the user activates the link.

## Syntax

```js-nolint
Expand All @@ -22,16 +28,49 @@ registerProtocolHandler(scheme, url)

- `scheme`

- : A string containing the [permitted scheme](#permitted_schemes) for the protocol that the site wishes to handle.
For example, you can register to handle SMS text message links by passing the `"sms"` scheme.
- : A string containing the scheme for the protocol that the site wishes to handle.

This may be a custom scheme, in which case the scheme's name:

- Begins with `web+`
- Contains at least one letter after the `web+` prefix
- Contains only lowercase {{Glossary("ASCII")}} letters.

Otherwise, the scheme must be one of the following:

- `bitcoin`
- `ftp`
- `ftps`
- `geo`
- `im`
- `irc`
- `ircs`
- `magnet`
- `mailto`
- `matrix`
- `mms`
- `news`
- `nntp`
- `openpgp4fpr`
- `sftp`
- `sip`
- `sms`
- `smsto`
- `ssh`
- `tel`
- `urn`
- `webcal`
- `wtai`
- `xmpp`

<!-- This must match: https://html.spec.whatwg.org/multipage/system-state.html#safelisted-scheme -->

- `url`

- : A string containing the URL of the handler.
**This URL must include `%s`**, as a placeholder that will be replaced with the [escaped](/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) URL to be handled.
This URL must include `%s`, as a placeholder that will be replaced with the [escaped](/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) URL to be handled.

> [!NOTE]
> The handler URL must use the `https` scheme. Older browsers also supported `http`.
The handler URL must use the `https` scheme, and must be of the same {{glossary("origin")}} as the webpage that is attemtping to register the handler.

### Return value

Expand All @@ -46,71 +85,29 @@ None ({{jsxref("undefined")}}).

- The registered scheme (protocol) is invalid, such as a scheme the browser handles itself (`https:`, `about:`, etc.)
- The handler URL's {{Glossary("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.
- The handler's URL's scheme is not `https`.

- `SyntaxError` {{domxref("DOMException")}}
- : The `%s` placeholder is missing from the handler URL.

## Permitted schemes

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 `web+`
- The custom scheme's name includes at least 1 letter after the `web+` prefix
- The custom scheme has only lowercase {{Glossary("ASCII")}} letters in its name.

For example, `web+burger`, as shown in the [Example](#examples) below.

Otherwise, the scheme must be one of the following:

- `bitcoin`
- `ftp`
- `ftps`
- `geo`
- `im`
- `irc`
- `ircs`
- `magnet`
- `mailto`
- `matrix`
- `mms`
- `news`
- `nntp`
- `openpgp4fpr`
- `sftp`
- `sip`
- `sms`
- `smsto`
- `ssh`
- `tel`
- `urn`
- `webcal`
- `wtai`
- `xmpp`

<!-- This must match: https://html.spec.whatwg.org/multipage/system-state.html#safelisted-scheme -->

## Examples

If your site is `burgers.example.com`, you can register a protocol handler for it to handle `web+burger:` links, like so:
In this example, a page served from `https://burgers.example.org/` contains a link like this:

```html
<a href="web+burger:cheeseburger">cheeseburger</a>
```

It registers the `web+burger` with code like this:

```js
navigator.registerProtocolHandler(
"web+burger",
"https://burgers.example.com/?burger=%s",
"https://burgers.example.org/?burger=%s",
);
```

This creates a handler that lets `web+burger:` links send the user to your site, inserting the accessed burger URL into the `%s` placeholder.

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 `http` or `https`.

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 on `google.co.uk`:

![A browser notification reads "Add Burger handler (www.google.co.uk) as an application for burger links?", and offers an "Add Application" button and a close to ignore the handler request.](protocolregister.png)
If the registration was successful, then if the user activates the `web+burger` link, the browser will navigate to `https://burgers.example.org/?burger=web+burger:cheeseburger`.

## Specifications

Expand All @@ -119,8 +116,3 @@ The user will be notified that your code asked to register the protocol handler,
## Browser compatibility

{{Compat}}

## See also

- [Web-based protocol handlers](/en-US/docs/Web/API/Navigator/registerProtocolHandler/Web-based_protocol_handlers)
- [RegisterProtocolHandler Enhancing the Federated Web](https://blog.mozilla.org/webdev/2010/07/26/registerprotocolhandler-enhancing-the-federated-web/) (Mozilla Webdev)

This file was deleted.

Binary file not shown.
2 changes: 1 addition & 1 deletion files/en-us/web/html/element/iframe/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ This element includes the [global attributes](/en-US/docs/Web/HTML/Global_attrib
- `allow-top-navigation-by-user-activation`
- : Lets the resource navigate the top-level browsing context, but only if initiated by a user gesture.
- `allow-top-navigation-to-custom-protocols`
- : Allows navigations to non-`http` protocols built into browser or [registered by a website](/en-US/docs/Web/API/Navigator/registerProtocolHandler/Web-based_protocol_handlers). This feature is also activated by `allow-popups` or `allow-top-navigation` keyword.
- : Allows navigations to non-`http` protocols built into browser or [registered by a website](/en-US/docs/Web/API/Navigator/registerProtocolHandler). This feature is also activated by `allow-popups` or `allow-top-navigation` keyword.

> [!NOTE]
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ where `<value>` can optionally be one of the following values:
- `allow-top-navigation-by-user-activation`
- : Lets the resource navigate the top-level browsing context, but only if initiated by a user gesture.
- `allow-top-navigation-to-custom-protocols`
- : Allows navigations to non-`http` protocols built into browser or [registered by a website](/en-US/docs/Web/API/Navigator/registerProtocolHandler/Web-based_protocol_handlers). This feature is also activated by `allow-popups` or `allow-top-navigation` keyword.
- : Allows navigations to non-`http` protocols built into browser or [registered by a website](/en-US/docs/Web/API/Navigator/registerProtocolHandler). This feature is also activated by `allow-popups` or `allow-top-navigation` keyword.

> [!NOTE]
> The `allow-top-navigation` and related values only make sense for embedded documents (such as child iframes). For standalone documents, these values have no effect, as the top-level browsing context is the document itself.
Expand Down

0 comments on commit deae7f2

Please sign in to comment.