I'm creating a website for a reading service for the blind and visually impaired and I'm using JavaScript (with jQuery) to print some stuff to some of the pages after the page has loaded.
Will the screen reader read the content that is printed to the page with jquery after the page has been loaded?
From this page - "Generally, [screen readers] access the DOM (Document Object Model), and they use browser APIs (Application Programming Interfaces) to get the information they need."
and we know that jQuery is a DOM manipulation library.
So the question becomes.. do screen readers take a copy of the whole DOM and then parse it and read it? Or do they read the DOM, the same one that jQuery works on?
Here's an example of one of the pages that I use JavaScript on. It uses a function that determines what program we have playing over the air and then prints the name of the program and a link to listen to it.
<div id="now-playing-div"></div>
<script>
// invoke the audio-reader javascript library
$( document ).ready( function() {
var callback = nowPlaying; // catalog, schedule, podcasts, archive or nowPlaying
var selector = '#now-playing-div';
makeAudioReaderPage(callback, selector);
});
</script>
So as you can see, if the screen reader doesn't read what the javascript/jquery prints to the #now-playing-div then it will read nothing. Then, we started getting a few emails of confused listeners wondering what happened to the Now Playing link.
So this morning I added this:
<div id='no-js'>Please enable JavaScript to receive this content.</div>
<script>
$( document ).ready( function() {
$('#no-js').toggle();
});
</script>
But if the problem isn't that JavaScript needs to be enabled (a recent survey shows that 99% of screen-reader users have JavaScript enabled) then the problem is not solved and is made even worse because now the screen reader user would think that JavaScript is not enabled.
What to do??