[Bug 21987] Consider adding a sister attribute to act as a toggle to trigger longdesc discoverability.

https://www.w3.org/Bugs/Public/show_bug.cgi?id=21987

--- Comment #4 from Charles McCathieNevile <chaals@yandex-team.ru> ---
(In reply to comment #3)
> (In reply to comment #2)
> > even so, script is not within the realms of everyone.
> 
> This is true. Not all authors know JavaScript or CSS. I don't see why the
> browser couldn't provide an easy way to do this, for authors of limited
> skill sets.

The browser could. But having the attribute won't make it happen either - what
is needed is the code, and getting it into a browser.

The simplest way to do that, of course, is an extension. Here's some horrible
code that could be used, but anyone who can write a browser extension (tens of
thousands of people can) would probably reject this code as hideous and write
something neater.

document.onload = (function(){
 function islinked(element) {
  if (element.tagName == 'A')
    return true;
  else if (element.tagName == 'BODY')
    return false;
  else
    return (islinked(i.parentElement));
 }
 function addlink(describedImage){
  var newLink = document.createElement('a');
  newLink.href = describedImage.longdesc;
  newLink.innerText = "[description of the image]";
  if (describedImage.nextSibling)
   
describedImage.parentElement.insertBefore((describedImage.nextSibling),newLink);
  else
    describedImage.parent.appendChild(newLink)
 }
//LinkNextToParent is a blend of the last two functions..
 var theimages = document.querySelectorAll('img[longdesc]');
 for (i in theimages) {
  if (! isLinked(i))
    addlink(i);
  else
    linkNextToParent(i);
 }

})

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Friday, 10 May 2013 22:11:32 UTC