aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/api/window/confirm/index.html
blob: f2895337bd5b38c7fa20cd881452cf7a63517e01 (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
---
title: Window.confirm()
slug: Web/API/Window/confirm
tags:
  - API
  - HTML DOM
  - Method
  - Reference
  - Window
translation_of: Web/API/Window/confirm
---
<div>{{ApiRef("Window")}}</div>

<p><code><strong>Window.confirm()</strong></code> 메서드는 확인과 취소 두 버튼을 가지며 메시지를 지정할 수 있는 모달 대화 상자를 띄웁니다.</p>

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

<pre class="syntaxbox notranslate"><em>result</em> = window.confirm(<em>message</em>);
</pre>

<h3 id="Parameters">Parameters</h3>

<dl>
 <dt><code>message</code></dt>
 <dd>경고 대화 상자에 표시할 텍스트 문자열.</dd>
</dl>

<h3 id="반환_값">반환 값</h3>

<p>확인 (<code>true</code>) 또는 취소 (<code>false</code>) 중 사용자가 선택한 값. 브라우저가 페이지 내 대화 상자를 무시하고 있으면 항상 <code>false</code>입니다.</p>

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

<pre class="brush: js notranslate">if (window.confirm("Do you really want to leave?")) {
  window.open("exit.html", "Thanks for Visiting!");
}
</pre>

<p>위 코드는 다음 결과를 보입니다.</p>

<p><img alt="firefox confirm" src="https://mdn.mozillademos.org/files/7163/firefoxcomfirmdialog_zpsf00ec381.png" style="height: 119px; width: 354px;"><br>
  </p>

<h2 id="참고">참고</h2>

<p>대화 상자는 모달 창(부모 창으로 돌아가기 전에 사용자의 상호 작용을 요구하는 자식 창)으로, 사용자는 대화 상자가 닫힐 때까지 다른 모든 인터페이스에 접근할 수 없습니다. 따라서 대화 상자(또는 모달 창)를 만드는 함수를 남용하면 안 됩니다. 이 뿐만이 아니더라도, <a href="https://alistapart.com/article/neveruseawarning/">대화 상자로 사용자 확인을 받는 것은 피해야</a> 할 좋은 이유 여럿이 존재합니다.</p>

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

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('HTML WHATWG', 'timers-and-user-prompts.html#dom-confirm', 'confirm()')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td></td>
  </tr>
 </tbody>
</table>

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



<p>{{Compat("api.Window.confirm")}}</p>

<h2 id="같이_보기">같이 보기</h2>

<ul>
 <li>{{domxref("window.alert()")}}</li>
 <li>{{domxref("window.prompt()")}}</li>
</ul>