navigator.registerProtocolHandler

  • Revision slug: DOM/navigator.registerProtocolHandler
  • Revision title: navigator.registerProtocolHandler
  • Revision id: 66693
  • Created:
  • Creator: paul.irish
  • Is current revision? No
  • Comment compat info; 14 words added

Revision Content

{{ DomRef() }} {{ Fx_minversion_header("3") }}

Summary

Allows web sites to register themselves as possible handlers for particular protocols.

{{ Note("Web sites may only register protocol handlers for themselves. For security reasons, it\'s not possible for an extension or web site to register protocol handlers targeting other sites.") }}

Syntax

window.navigator.registerProtocolHandler(protocol, uri, title);
  • protocol is the protocol the site wishes to handle, specified as a string.
  • uri is the URI to the handler as a string. You can include "%s" to indicate where to insert the escaped URI of the document to be handled.
  • title is the title of the handler presented to the user as a string.

Example

If your web application is located at http://www.example.com, you can register a protocol handler for it to handle "mailto" like this:

navigator.registerProtocolHandler("mailto",
                                  "https://www.example.com/?uri=%s",
                                  "Example Mail");


This creates a handler that allows mailto links to direct the user to your web application, inserting the email address specified in the link into the URL.

Specification

Specified by the WHATWG's Web Applications 1.0 working draft (HTML5).

Compatibility

Firefox: supported as of FF3

Chrome: supported as of Chrome 12

See also

{{ languages( { "es": "es/DOM/window.navigator.registerProtocolHandler", "fr": "fr/DOM/window.navigator.registerProtocolHandler", "ja": "ja/DOM/window.navigator.registerProtocolHandler", "pl": "pl/DOM/window.navigator.registerProtocolHandler", "ko": "ko/DOM/window.navigator.registerProtocolHandler" } ) }}

Revision Source

<p>{{ DomRef() }} {{ Fx_minversion_header("3") }}</p>
<h3 name="Summary">Summary</h3>
<p>Allows web sites to register themselves as possible handlers for particular protocols.</p>
<p>{{ Note("Web sites may only register protocol handlers for themselves. For security reasons, it\'s not possible for an extension or web site to register protocol handlers targeting other sites.") }}</p>
<h3 name="Syntax">Syntax</h3>
<pre class="eval">window.navigator.registerProtocolHandler(<em>protocol</em>, <em>uri</em>, <em>title</em>);
</pre>
<ul> <li><code>protocol</code> is the protocol the site wishes to handle, specified as a string.</li> <li><code>uri</code> is the URI to the handler as a string. You can include "%s" to indicate where to insert the escaped URI of the document to be handled.</li> <li><code>title</code> is the title of the handler presented to the user as a string.</li>
</ul>
<h3 name="Example">Example</h3>
<p>If your web application is located at <span class="nowiki">http://www.example.com</span>, you can register a protocol handler for it to handle "mailto" like this:</p>
<pre class="eval">navigator.registerProtocolHandler("mailto",
                                  "<a class=" link-https" href="https://www.example.com/?uri=%s" rel="freelink">https://www.example.com/?uri=%s</a>",
                                  "Example Mail");
</pre>
<p><br>
This creates a handler that allows mailto links to direct the user to your web application, inserting the email address specified in the link into the URL.</p>
<h3 name="Specification">Specification</h3>
<p>Specified by the WHATWG's <a class="external" href="http://whatwg.org/specs/web-apps/current-work/#custom-handlers">Web Applications 1.0 working draft</a> (HTML5).</p>
<h3 name="See_also">Compatibility</h3>
<p>Firefox: supported as of FF3</p>
<p>Chrome: supported as of Chrome 12</p>
<h3 name="See_also">See also</h3>
<ul> <li><a href="/en/Web-based_protocol_handlers" title="en/Web-based_protocol_handlers">Web-based protocol handlers</a></li> <li><a class=" external" href="http://blog.mozilla.com/webdev/2010/07/26/registerprotocolhandler-enhancing-the-federated-web/" title="http://blog.mozilla.com/webdev/2010/07/26/registerprotocolhandler-enhancing-the-federated-web/">RegisterProtocolHandler Enhancing the Federated Web</a> at Mozilla Webdev</li>
</ul>
<p>{{ languages( { "es": "es/DOM/window.navigator.registerProtocolHandler", "fr": "fr/DOM/window.navigator.registerProtocolHandler", "ja": "ja/DOM/window.navigator.registerProtocolHandler", "pl": "pl/DOM/window.navigator.registerProtocolHandler", "ko": "ko/DOM/window.navigator.registerProtocolHandler" } ) }}</p>
Revert to this revision