The Navigator method unregisterProtocolHandler() removes a protocol handler for a given URL scheme.
This method is the inverse of registerProtocolHandler().
unregisterProtocolHandler(scheme, url)
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
If your site is burgers.example.com, and you have a web+burger: scheme, you can unregister the handler for it like so:
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.