blob: 4a858777d686d0da9c923fbe2b00fd7de9236bbb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
---
title: Navigator.registerContentHandler()
slug: Web/API/Navigator/registerContentHandler
translation_of: Web/API/Navigator/registerContentHandler
---
<div>{{ ApiRef("HTML DOM") }}</div>
<h3 id="Summary" name="Summary">概述</h3>
<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>
<h3 id="Syntax" name="Syntax">语法</h3>
<pre class="brush: js">window.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>
<h3 id="Example" name="Example">例子</h3>
<pre class="brush: js">navigator.registerContentHandler("application/vnd.mozilla.maybe.feed",
"<span class="plain">http://www.example.tld/?foo=%s</span>",
"My Feed Reader");
</pre>
<h3 id="Notes" name="Notes">备注</h3>
<p>For <a href="/zh-cn/Firefox_2_for_developers" title="zh-cn/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>
<h3 id="Specification" name="Specification">规范</h3>
<p>WHATWG's <a class="external" href="http://whatwg.org/specs/web-apps/current-work/#custom-handlers">Web Applications 1.0 工作草案</a></p>
<h3 id="相关链接">相关链接</h3>
<ul>
<li><a href="/zh-cn/Web-based_protocol_handlers" title="zh-cn/Web-based_protocol_handlers">Web-based protocol handlers</a></li>
<li><a href="/zh-cn/nsIContentHandler" title="zh-cn/nsIContentHandler">nsIContentHandler</a> (XUL only)</li>
</ul>
<p>{{ languages( { "ja": "ja/DOM/window.navigator.registerContentHandler", "en": "en/DOM/window.navigator.registerContentHandler", "pl": "pl/DOM/window.navigator.registerContentHandler" } ) }}</p>
|