Skip to content

Commit

Permalink
Switch between polite and assertive
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw authored Jan 8, 2025
1 parent f34d1d0 commit 30ad8d4
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions aria-live-regions.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
font-size: 16px;
}

.controls {
margin-bottom: 20px;
}

select {
font-size: 16px;
padding: 4px;
margin-left: 8px;
}

button {
background: #0066cc;
border: none;
Expand Down Expand Up @@ -126,8 +136,16 @@ <h3>Testing with VoiceOver on iOS</h3>
</section>

<h2>Demo</h2>

<div class="controls">
<label for="liveType">Live region type: </label>
<select id="liveType">
<option value="assertive">Assertive</option>
<option value="polite">Polite</option>
</select>
</div>

<div>
<div class="demo-buttons">
<button id="notifyNow">Insert notification now</button>
<button id="notifyLater">Insert notification in ten seconds</button>
</div>
Expand All @@ -138,6 +156,11 @@ <h2>Demo</h2>
const notificationElement = document.getElementById('notification')
const notifyNowButton = document.getElementById('notifyNow')
const notifyLaterButton = document.getElementById('notifyLater')
const liveTypeSelect = document.getElementById('liveType')

liveTypeSelect.addEventListener('change', (event) => {
notificationElement.setAttribute('aria-live', event.target.value)
})

function insertNotification() {
const time = new Date().toLocaleTimeString()
Expand All @@ -156,4 +179,4 @@ <h2>Demo</h2>
})
</script>
</body>
</html>
</html>

0 comments on commit 30ad8d4

Please sign in to comment.