Last active
August 29, 2015 14:05
-
-
Save sTiLL-iLL/cc7e02af16234b2c37ca to your computer and use it in GitHub Desktop.
html5 dialog snips
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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