From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/html/element/dialog/index.html | 186 ++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 files/ja/web/html/element/dialog/index.html (limited to 'files/ja/web/html/element/dialog/index.html') diff --git a/files/ja/web/html/element/dialog/index.html b/files/ja/web/html/element/dialog/index.html new file mode 100644 index 0000000000..0d3cc585b1 --- /dev/null +++ b/files/ja/web/html/element/dialog/index.html @@ -0,0 +1,186 @@ +--- +title: ': ダイアログ要素' +slug: Web/HTML/Element/dialog +tags: + - Dialog + - Experimental + - HTML + - HTML 対話操作 + - 'HTML:フローコンテンツ' + - 'HTML:区分化ルート' + - Reference + - ウェブ + - ダイアログ + - 要素 +translation_of: Web/HTML/Element/dialog +--- +
{{HTMLRef}}
+ +

HTML の <dialog> 要素は、ダイアログボックスや、消すことができるアラート、インスペクター、サブウィンドウ等のような対話的コンポーネントを表します。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
コンテンツカテゴリフローコンテンツ, 区分化ルート
許可された内容フローコンテンツ
タグの省略{{no_tag_omission}}
許可された親要素フローコンテンツを受け入れるあらゆる要素
暗黙の ARIA ロールdialog
許可された ARIA ロール{{ARIARole("alertdialog")}}
DOM インターフェイス{{domxref("HTMLDialogElement")}}
+ +

属性

+ +

この要素にはグローバル属性があります。

+ +
+

tabindex 属性を <dialog> 要素で使用してはいけません。

+
+ +
+
{{htmlattrdef("open")}}
+
ダイアログがアクティブで操作で使用できることを示します。 open 属性が設定されていないときは、ダイアログはユーザーに表示するべきではありません
+
+ +

使用上の注意

+ + + +

+ +

シンプルな例

+ +
<dialog open>
+  <p>Greetings, one and all!</p>
+</dialog>
+
+ +

応用的な例

+ +

この例では、 "Update details" ボタンをクリックすると、フォームを含むポップアップダイアログボックスが開きます。

+ +

HTML

+ +
<!-- Simple pop-up dialog box containing a form -->
+<dialog id="favDialog">
+  <form method="dialog">
+    <p><label>Favorite animal:
+      <select>
+        <option></option>
+        <option>Brine shrimp</option>
+        <option>Red panda</option>
+        <option>Spider monkey</option>
+      </select>
+    </label></p>
+    <menu>
+      <button value="cancel">Cancel</button>
+      <button id="confirmBtn" value="default">Confirm</button>
+    </menu>
+  </form>
+</dialog>
+
+<menu>
+  <button id="updateDetails">Update details</button>
+</menu>
+
+<output aria-live="polite"></output>
+
+ +

JavaScript

+ +
var updateButton = document.getElementById('updateDetails');
+var favDialog = document.getElementById('favDialog');
+var outputBox = document.querySelector('output');
+var selectEl = document.querySelector('select');
+var confirmBtn = document.getElementById('confirmBtn');
+
+// "Update details" button opens the <dialog> modally
+updateButton.addEventListener('click', function onOpen() {
+  if (typeof favDialog.showModal === "function") {
+    favDialog.showModal();
+  } else {
+    alert("The <dialog> API is not supported by this browser");
+  }
+});
+// "Favorite animal" input sets the value of the submit button
+selectEl.addEventListener('change', function onSelect(e) {
+  confirmBtn.value = selectEl.value;
+});
+// "Confirm" button of form triggers "close" on dialog because of [method="dialog"]
+favDialog.addEventListener('close', function onClose() {
+  outputBox.value = favDialog.returnValue + " button clicked - " + (new Date()).toString();
+});
+ +

結果

+ +

{{EmbedLiveSample("Advanced_example", "100%", 300)}}

+ +

仕様書

+ + + + + + + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('HTML WHATWG', 'forms.html#the-dialog-element', '<dialog>')}}{{Spec2('HTML WHATWG')}}
{{SpecName('HTML5.2', 'interactive-elements.html#the-dialog-element', '<dialog>')}}{{Spec2('HTML5.2')}}初回定義
+ +

ブラウザーの互換性

+ + + +

{{Compat("html.elements.dialog")}}

+ +

ポリフィル

+ +

<dialog> 要素のないブラウザーには、このポリフィルを含めてください。

+ +

dialog-polyfill

+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf