大网数据广告活动
Web 标准与前端开发

Navigator: unregisterProtocolHandler() method

· 52CE 我爱测

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

HTML DOM

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

This method is the inverse of registerProtocolHandler().

Syntax

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:

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

Browser compatibility

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。