blob: 75e1645d14805c536840f0188afff57ad0955318 [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001<!DOCTYPE html>
2<html>
3<meta charset='utf-8'>
4<head>
5<script src="../dist/dialog-polyfill.js"></script>
6<link rel="stylesheet" type="text/css" href="../dist/dialog-polyfill.css">
7</head>
8<body>
9
10 <p>
11Enter a value and submit the form. The close event will be fired and the <code>returnValue</code> of the dialog will be alerted.
12 </p>
13
14<input type="text" placeholder="Focusable pre" />
15
16<dialog>
17 <form method="dialog">
18 <input type="text" placeholder="Enter value" />
19 <input type="reset" value="Reset" />
20 <input type="submit" value="Stuff" />
21 <input type="submit" value="Done" />
22 <button type="submit" value="Button Value Is Different Than Text">Button Submit</button>
23 <button value="Regular Button Value">Button</button>
24 </form>
25</dialog>
26
27<button id="show">Show Dialog</button>
28
29<input type="text" placeholder="Focusable post" />
30
31
32<script>
33var dialog = document.querySelector('dialog');
34dialogPolyfill.registerDialog(dialog);
35dialog.showModal();
36
37dialog.addEventListener('close', function() {
38 var valueEl = dialog.querySelector('input[type="text"]');
39 alert(dialog.returnValue);
40});
41
42show.addEventListener('click', function() {
43 dialog.showModal();
44});
45
46</script>
47</body>
48</html>