SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot imouto's Avatar
    Join Date
    Sep 2004
    Location
    Gotham
    Posts
    184
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    How to make this hide/show function screen reader-friendly?

    Those of you who've read Jeremy Keith's DOM Scripting book will recognize this page. I've been mucking around with the Javascript for a project I'm working on which more or less uses similar code from Keith's book. Here's the page with the showSection function:

    http://www.wuworkshop.com/test/domsters/about.html

    It starts off with the content for Jay Script, and when you click on the link called The Domsters the Jay Script content is hidden and you see the content for The Domsters.

    This was all fine and dandy till I checked my project using the JAWS screen reader. When I click on a link JAWS doesn't read the new content. Using the Tab key didn't make any difference. Can someone tell me how I can make this screen reader accessible?

    Code:
    function showSection(id) {
      var divs = document.getElementsByTagName("div");
      for (var i=0; i<divs.length; i++ ) {
        if (divs[i].className.indexOf("section") == -1) continue;
        if (divs[i].getAttribute("id") != id) {
          divs[i].style.display = "none";
        } else {
          divs[i].style.display = "block";
        }
      }
      var inLinks = document.getElementById("internalnav").getElementsByTagName("a");
      for (var i = 0; i < inLinks.length; i++) {
        if (inLinks[i].href.split("#")[1] == id) {
          inLinks[i].className = "currentSection";
        } else {
          inLinks[i].className = "";
        }
      }
    }
    
    function prepareInternalnav() {
      if (!document.getElementsByTagName) return false;
      if (!document.getElementById) return false;
      if (!document.getElementById("internalnav")) return false;
      var nav = document.getElementById("internalnav");
      var links = nav.getElementsByTagName("a");
      for (var i=0; i<links.length; i++ ) {
        var sectionId = links[i].getAttribute("href").split("#")[1];
        if (!document.getElementById(sectionId)) continue;
        document.getElementById(sectionId).style.display = "none";
        links[i].destination = sectionId;
        links[i].onclick = function() {
          showSection(this.destination);
          return false;
        }
        showSection("jay");
    }
    }

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    4 Thread(s)
    The return false disables the default link behaviour.

    If JAWS understands scripting then this will cause trouble. You can tell if the scripting is causing trouble by disabling the scripts and seeing if JAWS behaves as expected.

    If that i the case, remove the return false and JAWS should behave itself.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Zealot imouto's Avatar
    Join Date
    Sep 2004
    Location
    Gotham
    Posts
    184
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pmw57 View Post
    The return false disables the default link behaviour.

    If JAWS understands scripting then this will cause trouble. You can tell if the scripting is causing trouble by disabling the scripts and seeing if JAWS behaves as expected.

    If that i the case, remove the return false and JAWS should behave itself.
    Removing return false didn't fix the JAWS issue. Is it possible that's it's the showSection function that's the issue? I was thinking that after reading this from CSS-Discuss: http://css-discuss.incutio.com/?page...aderVisibility

    But I haven't the foggiest clue how to use the Off-Left technique they mention on that page. Any suggestions? Do I need to complete redo my Javascript?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •