Navigator: unregisterProtocolHandler() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The Navigator method unregisterProtocolHandler() removes a protocol handler for a given URL scheme.

This method is the inverse of registerProtocolHandler().

Syntax

js
unregisterProtocolHandler(scheme, url)

Parameters

scheme

A string containing the permitted scheme in the protocol handler that will be unregistered. For example, you can unregister the handler for SMS text message links by passing the "sms" scheme.

url

A string containing the URL of the handler. This URL should match the one that was used to register the handler (e.g., it must include %s).

Return value

None (undefined).

Exceptions

SecurityError DOMException

The user agent blocked unregistration. This might happen if:

  • The scheme (protocol) is invalid, such as a scheme the browser handles itself (https:, about:, etc.)
  • 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.
SyntaxError DOMException

The %s placeholder is missing from the handler URL.

Permitted schemes

For security reasons, unregisterProtocolHandler() restricts which schemes can be unregistered.

A custom scheme may be unregistered 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 ASCII letters in its name.

For example, web+burger, as shown in the Example 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

Examples

If your site is burgers.example.com, and you have a web+burger: scheme, you can unregister the handler for it like so:

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

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.

Specifications

Specification
HTML
# dom-navigator-unregisterprotocolhandler-dev

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Node.js
unregisterProtocolHandler
Chrome – Full support
Chrome 38 (Release date: 2014-10-07)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – No support
Opera 12.1 – 12.1 (Release date: 2012-11-20)
footnote Removed in 15 and later
Opera – Full support
Opera 25 (Release date: 2014-10-15)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – No support
Chrome Android
footnote
footnote See bug 40964464
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote
footnote See bug 40964464
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote
footnote See bug 40964464
WebView Android – No support
WebView Android
footnote
footnote See bug 40964464
WebView on iOS – No support
WebView on iOS
footnote No support
Node.js – No support
Node.js
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.
Has more compatibility info.