blob: 75e1645d14805c536840f0188afff57ad0955318 [file] [log] [blame]
<!DOCTYPE html>
<html>
<meta charset='utf-8'>
<head>
<script src="../dist/dialog-polyfill.js"></script>
<link rel="stylesheet" type="text/css" href="../dist/dialog-polyfill.css">
</head>
<body>
<p>
Enter a value and submit the form. The close event will be fired and the <code>returnValue</code> of the dialog will be alerted.
</p>
<input type="text" placeholder="Focusable pre" />
<dialog>
<form method="dialog">
<input type="text" placeholder="Enter value" />
<input type="reset" value="Reset" />
<input type="submit" value="Stuff" />
<input type="submit" value="Done" />
<button type="submit" value="Button Value Is Different Than Text">Button Submit</button>
<button value="Regular Button Value">Button</button>
</form>
</dialog>
<button id="show">Show Dialog</button>
<input type="text" placeholder="Focusable post" />
<script>
var dialog = document.querySelector('dialog');
dialogPolyfill.registerDialog(dialog);
dialog.showModal();
dialog.addEventListener('close', function() {
var valueEl = dialog.querySelector('input[type="text"]');
alert(dialog.returnValue);
});
show.addEventListener('click', function() {
dialog.showModal();
});
</script>
</body>
</html>