[script techs] 2.2 dynamic content generation

I am trying to understand what section 2.2 of
   http://www.w3.org/TR/2004/WD-WCAG20-SCRIPT-TECHS-20041119/
is about, so far I think there are errors in it which make it difficult 
to grasp the accessibility issues it wants to raise.

I don't understand why the task says
   "Avoid ... innerHTML()"
and the text
   "... the document.write() and innerHTML() methods "
as in my view innerHTML is not a method so those brackets "()" after 
"innerHTML" have no place there at all. I strongly suggest to remove 
those brackets after innerHTML and to not call innerHTML a method, it is 
a property. That section might raise valid issues about accessibility 
problems with innerHTML but if you use the wrong terminology you are 
more likely going to confuse the average scripter than convince him.


Furthermore, the section shows the following JavaScript code as a 
deprecated example:

function fillContent() {
	document.write("<h1>Welcome to my site</h1>");
	document.write("<p>Lorem ipsum dolor sit amet");
	document.menu.innerHTML = "<ul><li><a href="foo.html">foo</a>";
}

and says about it: "This deprecated example shows a script that inserts 
a header, a paragraph (which is unterminated, and thus invalid), and a 
list (again, invalid) into a given document."

Now in my understanding talking about validity of markup or a document 
only makes sense if you name a particular DTD against which you want to 
validate. The section doesn't name one so I can only assume that it has 
a HTML 4.01 DTD in mind when speaking about valididity. The HTML 4.01 
specification at
   http://www.w3.org/TR/html4/struct/text.html#h-9.3.1
clearly marks the end tag of the P element as being optional so I fail 
to see why the unterminated P in
   document.write("<p>Lorem ipsum dolor sit amet");
is invalid, whether you write static HTML or document.write dynamic HTML 
it is parsed by the same rules and therefore I don't think that example 
line shows anything done with document.write which is invalidating the 
document.

Further on that example, while the line
   document.menu.innerHTML = "<ul><li><a href="foo.html">foo</a>";
with a closing mandatory </ul> missing might make for an example 
illustrating invalid markup the line will raise a syntax error before it 
comes to that, the inner quotes in the JavaScript string need to be 
escaped so you need to make that line
   document.menu.innerHTML = "<ul><li><a href=\"foo.html\">foo</a>";
to have a syntactically correct example which then causes semantic issues.


-- 

	Martin Honnen
	

Received on Saturday, 20 November 2004 17:31:42 UTC