What should the HREF attribute for javascript links on a page compatible with 508?

I know this question: What is the "href" value that I should use for JavaScript links, "" or "javascript: void (0)"? contains a discussion of what the correct href content should be for javascript links. How does this compare to compliance with 508? Does anyone know if javascript: void (0) is suitable when click handlers are defined elsewhere in javascript code?

+4
source share
2 answers

Here the terminology becomes important - from the point of view of accessibility there is no such thing as a "link to javascript". There are links that are pure anchor elements, and there is javascript behavior that should be considered invalid for accessibility.

The empty anchor element that runs javascript (so something like href = '#' onclick = '...') is not a link, it is a user interface element for triggering page behavior. For accessibility, do not abuse the binding element for this, use a real user interface element with the correct ARIA role.

To navigate by click (which does something like "click anchor" โ†’ "magical JS is called" โ†’ "window.location changed to some new page"), then keep in mind that you are semanticlaly, distorting your content. Although you use a binding element, your use is not a link, because it is not a binding to another resource. As in the above case, this is actually a button. The fact that the page layout changes at the end does not change this.

For true accessibility, you will have to abandon any JavaScript in the middle. But donโ€™t worry, this is much less severe than it seems: the easiest solution is to use cross-references. If you have ever used google.com or duckduckgo.com, etc., you will already be familiar with this: instead of linking to the actual URL, the link to the proxy server URL on the script page. You can ensure that linking to the URL " http://our.domain.com/ref=http://the.actual.link.to.visit " will result in a redirect to the actual site, and you can any desired operation that should be performed "when people click" as an action on the server side when redirection is enabled.

Matching 508 will be tricky if you think you rely on JavaScript. Therefore, for accessibility: I actively try not to do this. Enrich, if you can use it, make sure that everything works without it.

+1
source

I essentially agree with Mike.

How does this compare to compliance with 508?

A common misconception regarding Section 508 is: "Oh, I launched my site with JAWS (or perhaps NVDA), and everything is fine, so I'm compatible." Section 508 is intended to cover all types of disabilities, not just blindness. When you are surprised at the serious JavaScripting, agencies tend to use Standard Applications and Operating Systems (1194.21) Standards in addition to Internet Intranet and Internet Information and Systems (1194.22) because they talk more about user interface elements . Places like WebAIM unfortunately deny this.

So, when 1194.21 is turned on, the standards can be more easily read as "you put all @alts and <label> , but can this site / application / system using the keyboard? AKA is the keyboard for navigation?" Can you go to a <span> that looks like a link?

As Mack said, one way to help with this is to use ARIA. So the <span> should now be:

 <span onclick="Clicky()" role="link">Link</span> 

(Ref: MDN )

Now back to your question:

I know this question: Href attribute for JavaScript links: "#" or "javascript: void (0)"? Does anyone know if javascript: void (0) is suitable when click handlers are defined elsewhere in javascript code?

I would advocate emptiness, because when the link (it seems that it is called the link on the page) is not defined, the focus returns to the browser frame, and does not remain on the link. You will need to write some handlers to return focus to the link.

0
source

All Articles