Windowクラスのconfirm()を使って、ユーザーから[Yes][No]を受け取ることのできるダイアログを表示します。
目次
種類
Windowクラスのメソッド
機能
ショートメッセージと[はい][いいえ]の2つのボタンのあるダイアログを表示。
[はい]のときtrue、[いいえ]のときfalseを返す。
構文
Window.confirm (message[, noAsDflt, title]);
- message
- ダイアログに表示するメッセージ
- noAsDflt
- オプション。
trueのとき、[いいえ]ボタンが選択された状態でダイアログが表示される。
デフォルトはfalse([はい]ボタンが選択)。 - title
- オプション。
ダイアログに表示するタイトル。設定しないときは「Script Alert」。
サンプルコードと実行結果1
var ret = Window.confirm("実行しますか?");
Window.alert(ret);
オプション指定なし。
[はい]ボタンが選択されていて、そのままEnterキーを押すとtrueが返る。


サンプルコードと実行結果2
var ret = Window.confirm("実行しますか?", false, "実行確認");
Window.alert(ret);
オプションnoAsDfltはデフォルトのfalse。
[はい]ボタンが選択されていて、そのままEnterキーを押すとtrueが返る。


サンプルコードと実行結果3
var ret = Window.confirm("とうする?", true, "取消し確認");
Window.alert(ret);
オプションnoAsDfltをtrue。
[いいえ]ボタンが選択されていて、そのままEnterキーを押すとfalseが返る。

