aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/api/window/alert/index.html
blob: 425d4f2849ee1281cc62c0e28c63fb45d2b9f990 (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
---
title: window.alert
slug: Web/API/Window/alert
tags:
  - API
  - DOM
  - Gecko
  - Method
  - Reference
  - Window
  - alert
translation_of: Web/API/Window/alert
---
<div>{{ApiRef}}</div>

<p><strong><code>Window.alert()</code></strong> メソッドは、オプションの指定されたコンテンツと OK ボタンを持つ警告ダイアログを表示します。</p>

<p>一部の条件下(ユーザーがタブを切り替えた場合など)では、ブラウザーが実際にダイアログを表示しない場合や、ユーザーがダイアログを閉じるのを待たない場合があります。</p>

<h2 id="Syntax" name="Syntax">構文</h2>

<pre class="syntaxbox"><code>window.alert(<em>message</em>);</code></pre>

<h3 id="Parameters" name="Parameters">パラメーター</h3>

<dl>
  <dt><code>message</code> {{optional_inline}}</dt>
  <dd>警告ダイアログに表示したいオプションの文字列または、文字列に変換されて表示されるオブジェクトです。</dd>
</dl>

<h2 id="Example" name="Example"></h2>

<pre class="brush: js">window.alert("Hello world!");
alert("Hello world!");</pre>

<p>いずれも、以下のように表示されます。</p>

<p><img alt="Image:AlertHelloWorld.png" src="/files/130/AlertHelloWorld.png"></p>

<h2 id="Notes" name="Notes">注記</h2>

<p>警告ダイアログは、メッセージの確認応答以外に、ユーザ側で応答を必要としないメッセージのために使われるべきです。</p>

<p>この記事では、 DOM:window.prompt と DOM:window.confirm のテキストが共有されています。ダイアログボックスはモーダルウィンドウです。つまり、ユーザーはこれを閉じないとプログラムの他のインターフェイス部分にアクセスする事ができません。ですから、ダイアログボックス (もしくは、モーダルウィンドウ) を生成する関数を過度に使用すべきではありません。</p>

<h2 id="Specification" name="Specification">仕様</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">仕様</th>
   <th scope="col">状態</th>
   <th scope="col">コメント</th>
  </tr>
  <tr>
   <td>{{SpecName('HTML WHATWG', 'timers-and-user-prompts.html#dom-alert', 'alert()')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="See_also" name="See_also">関連情報</h2>

<ul>
 <li>{{domxref("window.confirm","confirm")}}</li>
 <li>{{domxref("window.prompt","prompt")}}</li>
 <li><a href="/ja/docs/Chrome">Mozilla Chrome</a> については、{{ifmethod("nsIPromptService","alert")}}{{ifmethod("nsIPromptService","alertCheck")}} を参照してください。</li>
</ul>