Reputation: 10383
I have a question about making dynamically set images obey accessibility standards.
Technically, it is possible to set the image alt text with JavaScript. However, when I "view source" of a page in which this is done, the alt text does not appear as an actual image attribute. If I set the title attribute using JavaScript, the tool tip works, showing that as far as the browser is concerned, the title attribute is set.
So, would a screen reader, or other method a blind person would use to read the page, see the alt text that was set in JavaScript?
Here is an example:
<html>
<script>
function set_image_properties(){
document.getElementById("image").src = "http://www.premiumbeat.com/blog/wp-content/uploads/2012/12/free.jpeg";
document.getElementById("image").alt = "free";
document.getElementById("image").title = "free";
}
</script>
<body onload="set_image_properties()">
<img id="image"/>
</body>
</html>
Upvotes: 0
Views: 2172
Reputation: 13539
As long as the device which open your page has Javascript enabled the user will see the effect. However, this will not work for a search engine crawlers for example.
Upvotes: 4