JavaScript Navigator unregisterProtocolHandler() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Method

Definition

navigator.unregisterProtocolHandler(scheme, url) removes a previously registered protocol handler for a URL scheme. It is the inverse of registerProtocolHandler() (MDN). Returns undefined.

Pass the required arguments shown below. Check return values and browser support before you rely on the result.

Syntax

Call navigator.unregisterProtocolHandler. Start with this line.

JavaScript
navigator.unregisterProtocolHandler(scheme, url)
CallWhat it does
navigator.unregisterProtocolHandler(scheme, url)Primary signature.
navigator.unregisterProtocolHandler(...)Call with the arguments your case needs.

Built into the browser. Call unregisterProtocolHandler(...) on a Navigator — no import required.

Library declarations
JavaScript
navigator.unregisterProtocolHandler(scheme, url)

Parameters

ParameterDescription
schemeRequired. Protocol to unregister (e.g. "web+burger")
urlRequired. Handler template with %s; must match registration

Return Value

Return ValueDescription
*Always undefined

JavaScript Examples

Example 1 — Feature-Detect

Check the method and secure context before calling.

JavaScript
const ok =
  "unregisterProtocolHandler" in navigator &&
  window.isSecureContext;

console.log(ok ? "ready to call" : "unavailable here");
Try It Yourself

How It Works

  1. Test in navigator. The method may be missing (not Baseline).
  2. Check isSecureContext. HTTPS / localhost required (MDN).
  3. Combine both. Only then attempt unregister.
  4. Keep a fallback. Unsupported browsers skip quietly.

Example 2 — Unregister a Handler

MDN shape: scheme + same-origin URL template with %s.

JavaScript
if (!("unregisterProtocolHandler" in navigator)) {
  console.log("not supported");
} else {
  try {
    const url = location.origin + "/?burger=%s";
    navigator.unregisterProtocolHandler("web+burger", url);
    console.log("called");
  } catch (err) {
    console.log(err.name); // SecurityError, …
  }
}
Try It Yourself

How It Works

  1. Detect first. Avoid calling a missing method.
  2. Build a same-origin URL. Use location.origin + %s.
  3. Pass scheme + url. Must match what registration used (MDN).
  4. Catch SecurityError. Blocked schemes or context rules may throw.

Example 3 — Missing %s Throws

Handler URLs without the %s placeholder raise SyntaxError (MDN).

JavaScript
if (!("unregisterProtocolHandler" in navigator)) {
  console.log("skip");
} else {
  try {
    navigator.unregisterProtocolHandler(
      "web+burger",
      location.origin + "/handler"
    );
  } catch (err) {
    console.log(err.name); // "SyntaxError"
  }
}
Try It Yourself

How It Works

  1. Detect the API. Exit early when missing.
  2. Omit %s. The URL is incomplete for a handler template.
  3. Engine throws SyntaxError. Documented on MDN.
  4. Always include %s. Same rule as registerProtocolHandler.

Browser Support

Navigator.unregisterProtocolHandler() is Limited availability (not Baseline) on MDN. It requires a secure context. It is not Deprecated, Experimental, or Non-standard.

✓ Limited · Not Baseline

Navigator.unregisterProtocolHandler()

Support is strongest in some Chromium-based browsers on HTTPS. Always feature-detect and keep a no-op fallback.

Limited Not Baseline
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
navigator.unregisterProtocolHandler() Limited

Bottom line: Feature-detect, use same-origin HTTPS templates with %s, and never assume Baseline support.

Frequently Asked Questions

MDN: Navigator.unregisterProtocolHandler() removes a protocol handler for a given URL scheme. It is the inverse of registerProtocolHandler().
No. MDN does not mark it Deprecated, Experimental, or Non-standard. It is Limited availability (not Baseline) and requires a secure context.
Yes. Pass the same scheme and the same handler URL (including %s) that were used with registerProtocolHandler() (MDN).
Yes. The API is a secure-context feature. The handler URL must be http/https and same-origin as the page calling unregister (MDN).
SecurityError when the scheme is blocked, origin/https rules fail, or the context is insecure. SyntaxError when %s is missing from the handler URL (MDN).
The same permitted list as registration: schemes like mailto, tel, sms, bitcoin, and custom web+… names that follow the lowercase ASCII rules (MDN).

Next: vibrate()

Learn how to pulse the device vibrator with navigator.vibrate().

vibrate() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful