Skip to content

Commit 30ad8d4

Browse files
authored
Switch between polite and assertive
1 parent f34d1d0 commit 30ad8d4

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

aria-live-regions.html

+25-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@
3030
font-size: 16px;
3131
}
3232

33+
.controls {
34+
margin-bottom: 20px;
35+
}
36+
37+
select {
38+
font-size: 16px;
39+
padding: 4px;
40+
margin-left: 8px;
41+
}
42+
3343
button {
3444
background: #0066cc;
3545
border: none;
@@ -126,8 +136,16 @@ <h3>Testing with VoiceOver on iOS</h3>
126136
</section>
127137

128138
<h2>Demo</h2>
139+
140+
<div class="controls">
141+
<label for="liveType">Live region type: </label>
142+
<select id="liveType">
143+
<option value="assertive">Assertive</option>
144+
<option value="polite">Polite</option>
145+
</select>
146+
</div>
129147

130-
<div>
148+
<div class="demo-buttons">
131149
<button id="notifyNow">Insert notification now</button>
132150
<button id="notifyLater">Insert notification in ten seconds</button>
133151
</div>
@@ -138,6 +156,11 @@ <h2>Demo</h2>
138156
const notificationElement = document.getElementById('notification')
139157
const notifyNowButton = document.getElementById('notifyNow')
140158
const notifyLaterButton = document.getElementById('notifyLater')
159+
const liveTypeSelect = document.getElementById('liveType')
160+
161+
liveTypeSelect.addEventListener('change', (event) => {
162+
notificationElement.setAttribute('aria-live', event.target.value)
163+
})
141164

142165
function insertNotification() {
143166
const time = new Date().toLocaleTimeString()
@@ -156,4 +179,4 @@ <h2>Demo</h2>
156179
})
157180
</script>
158181
</body>
159-
</html>
182+
</html>

0 commit comments

Comments
 (0)