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.
source share