Skip to content

Instantly share code, notes, and snippets.

@sTiLL-iLL
Last active August 29, 2015 14:05
Show Gist options
  • Save sTiLL-iLL/cc7e02af16234b2c37ca to your computer and use it in GitHub Desktop.
Save sTiLL-iLL/cc7e02af16234b2c37ca to your computer and use it in GitHub Desktop.
html5 dialog snips
<!doctype html>
<html>
<head>
<title>Dialog Test</title>
<style>
dialog::backdrop {
background: rgba(255, 0, 255, 0.25);
}
</style>
</head>
<body>
<dialog>
<p>
ChekUm oUtEm.... lorem fuckem lipsum...
</p>
<form method="dialog">
<button type="submit" value="yes">Accept</button>
<button type="submit" value="no">Reject</button>
</form>
</dialog>
</body>
</html>
document.getElementsByTagName("span")[0].addEventListener("click", function() {
document.getElementsByTagName("dialog")[0].show();
}, false);
document.getElementsByTagName("dialog")[0].addEventListener("click", function() {
this.close();
}, false);
document.getElementsByTagName("dialog")[0].addEventListener("close", function(e) {
var answer = this.returnValue;
}, false);
document.getElementsByTagName("dialog")[0].addEventListener("cancel", function(e) {
var answer = "cancelled";
}, false);
document.getElementsByTagName("dialog")[0].showModal();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment