aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/api/navigator/registerprotocolhandler/index.html
blob: 1b146a356e013368249e0205184b1cd94770a5a3 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
---
title: Navigator.registerProtocolHandler()
slug: Web/API/Navigator/registerProtocolHandler
tags:
  - API
  - DOM
  - Method
  - Navigator
  - Reference
translation_of: Web/API/Navigator/registerProtocolHandler
---
<div>{{APIRef("HTML DOM")}}{{securecontext_header}}</div>

<p><span class="seoSummary"><strong><code>Navigator.registerProtocolHandler()</code></strong> 메서드는 웹 사이트가 특정 {{glossary("URL")}} 스킴("프로토콜")을 열거나 처리할 수 있도록 등록합니다.</span> 이를테면, 이메일 사이트가 <code>mailto:</code> URL에, <abbr title="Voice over Internet Protocol, 인터넷 전화">VoIP</abbr> 사이트가 <code>tel:</code> URL에 자신을 등록할 때 사용할 수 있습니다.</p>

<h2 id="구문">구문</h2>

<pre class="syntaxbox">navigator.registerProtocolHandler(<var>protocol</var>, <var>url</var>, <var>title</var>);</pre>

<h3 id="매개변수">매개변수</h3>

<dl>
 <dt><code>protocol</code></dt>
 <dd>웹 사이트가 처리하고자 하는 프로토콜 문자열. 예컨대 SMS 문자 메시지를 처리하고자 한다면 <code>"sms"</code>를 전달하세요.</dd>
 <dt><code>url</code></dt>
 <dd>처리기의 URL. <strong>플레이스홀더로 사용할 <code>%s</code>를 반드시 포함</strong>해야 합니다. 실제 사용 시, <code>%s</code>에는 처리 대상 URL을 <a href="/ko/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent">이스케이프 처리</a>해 대입합니다.
 <div class="note"><strong>참고:</strong> 처리기의 URL은 반드시 <code>http</code> 또는 <code>https</code> 스킴을 필요로 합니다. 일부 브라우저는 보안상 <code>https</code>를 요구하므로 <code>https</code>를 사용하는 편이 좋습니다.</div>
 </dd>
 <dt><code>title</code></dt>
 <dd>사람이 읽을 수 있는 형태의 처리기 이름. 브라우저 설정 등 처리기 목록에서 <strong>사용자에게 보이는 이름</strong>입니다.</dd>
</dl>

<h3 id="예외">예외</h3>

<dl>
 <dt><code>SecurityError</code></dt>
 <dd>{{glossary("user agent", "사용자 에이전트")}}가 등록을 막았습니다. 다음 상황에서 발생할 수 있습니다.
 <ul>
  <li>등록하려는 스킴(프로토콜)이 유효하지 않습니다. 브라우저가 직접 처리하는 스킴을 등록하려 하면 발생합니다. (<code>https:</code>, <code>about:</code>, ...)</li>
  <li>처리기 URL의 {{glossary("출처")}}가 API를 호출한 페이지 출처와 일치하지 않습니다.</li>
  <li>브라우저가 보안 맥락에서의 <code>registerProtocolHandler()</code> 호출을 요구합니다.</li>
  <li>브라우저가 처리기 URL의 HTTPS 사용을 요구합니다.</li>
 </ul>
 </dd>
 <dt><code>SyntaxError</code></dt>
 <dd>처리기 URL에 <code>%s</code> 플레이스홀더가 없습니다.</dd>
</dl>

<h2 id="가능한_스킴">가능한 스킴</h2>

<p>보안상의 이유로, <code>registerProtocolHandler()</code>가 등록할 수 있는 스킴은 제한적입니다.</p>

<p><strong>사용자 지정 스킴</strong>은 다음 조건을 만족해야 합니다.</p>

<ul>
 <li>스킴이 <code>web+</code>로 시작합니다.</li>
 <li><code>web+</code> 접두사 뒤에 다른 글자가 최소 하나 존재해야 합니다.</li>
 <li>소문자 ASCII 문자로만 구성해야 합니다.</li>
</ul>

<p>아래 {{anch("예제")}}에서 사용한 <code>web+burger</code>는 제약조건을 만족하는 사용자 지정 스킴입니다.</p>

<p>그 외에는 다음 스킴을 등록할 수 있습니다.</p>

<div class="threecolumns">
<ul>
 <li><code>bitcoin</code></li>
 <li><code>geo</code></li>
 <li><code>im</code></li>
 <li><code>irc</code></li>
 <li><code>ircs</code></li>
 <li><code>magnet</code></li>
 <li><code>mailto</code></li>
 <li><code>mms</code></li>
 <li><code>news</code></li>
 <li><code>nntp</code></li>
 <li><code>openpgp4fpr</code></li>
 <li><code>sip</code></li>
 <li><code>sms</code></li>
 <li><code>smsto</code></li>
 <li><code>ssh</code></li>
 <li><code>tel</code></li>
 <li><code>urn</code></li>
 <li><code>webcal</code></li>
 <li><code>wtai</code></li>
 <li><code>xmpp</code></li>
</ul>
</div>

<h2 id="예제">예제</h2>

<p>사이트 주소가 <code>burgers.example.com</code>인 경우, 아래 코드로 <code>web+burger:</code> 스킴에 대한 처리기를 등록할 수 있습니다.</p>

<pre class="brush: js">navigator.registerProtocolHandler("web+burger",
                                  "https://burgers.example.com/?burger=%s",
                                  "Burger handler");</pre>

<p>이제, <code>web+burger:</code> 링크는 사용자를 <code>burgers.example.com</code>로 보내고, 자신의 URL을 <code>%s</code> 위치에 삽입합니다.</p>

<p>이때, 예제 코드는 처리기 URL과 같은 {{glossary("출처")}}를 가져야 하므로 <code>https://burgers.example.com</code>의 페이지 안에서 호출해야 하며, 처리기 URL은 <code>http</code>/<code>https</code>를 사용해야 합니다.</p>

<h2 id="명세">명세</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('HTML WHATWG', 'system-state.html#custom-handlers', 'registerProtocolHandler()')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="브라우저_호환성">브라우저 호환성</h2>



<p>{{Compat("api.Navigator.registerProtocolHandler")}}</p>