82 lines
2.6 KiB
HTML
82 lines
2.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Benachrichtigungs-Test</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
height: 100vh;
|
|
background-color: #f0f0f0;
|
|
margin: 0;
|
|
text-align: center;
|
|
}
|
|
.container {
|
|
background-color: white;
|
|
padding: 40px;
|
|
border-radius: 10px;
|
|
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
|
|
}
|
|
h1 {
|
|
color: #333;
|
|
}
|
|
p {
|
|
color: #666;
|
|
margin-bottom: 20px;
|
|
}
|
|
button {
|
|
padding: 12px 24px;
|
|
font-size: 16px;
|
|
border: none;
|
|
border-radius: 5px;
|
|
background-color: #007bff;
|
|
color: white;
|
|
cursor: pointer;
|
|
transition: background-color 0.3s ease;
|
|
}
|
|
button:hover {
|
|
background-color: #0056b3;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>Test für Browser-Benachrichtigungen</h1>
|
|
<p>Klicke auf den Knopf, um eine Test-Benachrichtigung auszulösen.</p>
|
|
<button id="testButton">Benachrichtigung senden</button>
|
|
</div>
|
|
|
|
<script>
|
|
document.getElementById('testButton').addEventListener('click', async () => {
|
|
// Schritt 1: Überprüfen und Erlaubnis anfordern
|
|
if (!('Notification' in window)) {
|
|
alert('Dieser Browser unterstützt keine Benachrichtigungen.');
|
|
return;
|
|
}
|
|
|
|
const permission = await Notification.requestPermission();
|
|
|
|
if (permission === 'granted') {
|
|
// Schritt 2: Benachrichtigung erstellen
|
|
const notification = new Notification('Test-Benachrichtigung', {
|
|
body: 'Herzlichen Glückwunsch, Benachrichtigungen funktionieren!',
|
|
icon: 'https://placehold.co/64x64/007bff/FFFFFF?text=OK'
|
|
});
|
|
|
|
// Schritt 3: Event-Listener für den Klick hinzufügen
|
|
notification.addEventListener('click', () => {
|
|
window.open('https://google.com', '_blank');
|
|
});
|
|
|
|
console.log('Test-Benachrichtigung gesendet.');
|
|
} else {
|
|
alert('Benachrichtigungsberechtigung wurde verweigert.');
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|