Navigator.registerContentHandler()

  • Revision slug: Web/API/window.navigator.registerContentHandler
  • Revision title: window.navigator.registerContentHandler
  • Revision id: 415601
  • Created:
  • Creator: Skierpage
  • Is current revision? No
  • Comment

Revision Content

{{DomRef()}}

Summary

Allows web sites to register themselves as possible handlers for content of a particular MIME type.

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

Syntax

navigator.registerContentHandler(mimeType, uri, title);
  • mimeType is the desired MIME type as a string.
  • uri is the URI to the handler as a string.
  • title is the title of the handler presented to the user as a string.

Example

navigator.registerContentHandler(
    "application/vnd.mozilla.maybe.feed",
    "http://www.example.tld/?foo=%s",
    "My Feed Reader"
);

Notes

For Firefox 2 and above, only the application/vnd.mozilla.maybe.feed, application/atom+xml, and application/rss+xml MIME types are supported. All values have the same effect, and the registered handler will receive feeds in all Atom and RSS versions (see {{Bug("391286")}}).

Specification

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

See also

Revision Source

<div>
  {{DomRef()}}</div>
<h2 id="Summary" name="Summary">Summary</h2>
<p>Allows web sites to register themselves as possible handlers for content of a particular MIME type.</p>
<p>{{Note("Web sites may only register content handlers for themselves. For security reasons, it\'s not possible for an extension or web site to register content handlers targeting other sites.")}}</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="syntaxbox">
navigator.registerContentHandler(<em>mimeType</em>, <em>uri</em>, <em>title</em>);</pre>
<ul>
  <li><code>mimeType</code> is the desired MIME type as a string.</li>
  <li><code>uri</code> is the URI to the handler as a string.</li>
  <li><code>title</code> is the title of the handler presented to the user as a string.</li>
</ul>
<h2 id="Example" name="Example">Example</h2>
<pre class="brush:js;auto-links:false;">
navigator.registerContentHandler(
    "application/vnd.mozilla.maybe.feed",
    "http://www.example.tld/?foo=%s",
    "My Feed Reader"
);</pre>
<h2 id="Notes" name="Notes">Notes</h2>
<p>For <a href="/en-US/docs/Firefox_2_for_developers" title="Firefox_2_for_developers">Firefox 2</a> and above, only the <code>application/vnd.mozilla.maybe.feed</code>, <code>application/atom+xml</code>, and <code>application/rss+xml</code> MIME types are supported. All values have the same effect, and the registered handler will receive feeds in all Atom and RSS versions (see {{Bug("391286")}}).</p>
<h2 id="Specification" name="Specification">Specification</h2>
<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>.</p>
<h2 id="See_also" name="See_also">See also</h2>
<ul>
  <li><a href="/en-US/docs/Web-based_protocol_handlers" title="Web-based_protocol_handlers">Web-based protocol handlers</a></li>
</ul>
Revert to this revision