Skip to content

Instantly share code, notes, and snippets.

@schmidt1024
Created October 13, 2022 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schmidt1024/bd0508cadb80ca7738bf613fa9b16347 to your computer and use it in GitHub Desktop.
Save schmidt1024/bd0508cadb80ca7738bf613fa9b16347 to your computer and use it in GitHub Desktop.
HTML JavaScript Notification
<!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