Created
October 13, 2022 08:39
-
-
Save cod3cow/bd0508cadb80ca7738bf613fa9b16347 to your computer and use it in GitHub Desktop.
HTML JavaScript Notification
This file contains 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 lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Notification Test</title> | |
</head> | |
<body> | |
<button id="btn">Test</button> | |
<script> | |
document.getElementById('btn').onclick = notify | |
function notify(){ | |
Notification.requestPermission().then(permission => { | |
if (permission === "granted"){ | |
new Notification("Test Notification", { | |
body: "More Text", | |
}) | |
} | |
}) | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment