W3C home > Mailing lists > Public > w3c-wai-gl@w3.org > July to September 2004

RE: [#1059] Prohibit URLs with javascript protocol

From: Doug Gibson <doug@dgibson.net>
Date: Tue, 21 Sep 2004 22:30:10 -0400
To: <w3c-wai-gl@w3.org>
Message-ID: <005601c4a04c$15ffa290$6e01a8c0@death>
Michael wrote: 
Links that use the Javascript protocol, e.g., 

 <a href="javascript:dosomething();">Javascript link</a>

are unusable by browsers that do not support JavaScript.

There should be a technique that advises authors not to use javascript
links. Instead, they should provide an http link to a fallback page, and
instantiate the desired script using event handlers. For example:

 <a href="fallback.html" onactivate="dosomething()">Good link</a> 
end Michael quote 
"a technique that advises authors not to use javascript links" is right
on. It seems too much to make it a requirement, but (correct me if I'm
wrong) you can do everything without the javascript: URI in the onclick
event handler. Making this a strong recommendation with explanation may
at least save many from needlessly using javascript: URIs and using them
in inaccessible ways.

While I agree that hrefs that use the JavaScript protocol are unusable
by browsers that do not support JavaScript,  I don't believe that is an
accessibility issue but rather a usability issue.  As a web developer I
should be able to make the decision of whether or not my site will run
with JavaScript turned off or not.  I believe that if my site uses
JavaScript AND it is accessible in a browser that supports JavaScript,
it should pass WCAG 2.0 at level 1.   

I don't follow the argument about being accessible in a browser
supporting JavaScript. That may not, but most often goes against
accessibility. Likewise if I replaced "JavaScript" with "CSS" or

One can argue that the web developer should always provide a fallback
url and use the second technique (although you should use the onclick
event rather than onactivate since the browsers implement onactivate
very differently).  But could I work around this by having the fallback
page state, "You must have a browser capable of JavaScript and have
JavaScript support turned on to use this site"?  I don't believe that is
what Michael intended but it could be a way to "work around" this
requirement without making the site any more usable.  And, if I am
required to create a working fallback page for each link, why even
bother to use JavaScript at all as I have just doubled my amount of
coding and have probably lost the benefits of using JavaScript in the
first place?   

Still, some applications will use JavaScript to do simple calculations
and stuff that does not require a fallback "page". What are the
limitations with stating the link requires JavaScript in the title
<a href="#" onclick="doThis(); return false;" title="Calculation
requires JavaScript">Link text</a>
How bad is it to use noscript as an inline element like below? (Humor
me). Is it structurally invalid even if declared inline in your CSS? It
was just something off the top of my head.
<a href="#" onclick="doThis(); return false;">Link text
<noscript>(requires JavaScript)</noscript></a> 
Doug Gibson 
Cold Fusion Web/Application Developer 
ICQ: 345916  AIM & YIM: dgibson666 
Received on Wednesday, 22 September 2004 02:30:30 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 16 January 2018 15:33:51 UTC