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

Scripting techniques - 2.2 Dynamic Content

From: Doug Gibson <doug.gibson@gmail.com>
Date: Fri, 19 Nov 2004 20:18:22 -0500
Message-ID: <30f68ab40411191718707a9dfa@mail.gmail.com>
To: w3c-wai-gl@w3.org

In 2.2 Dynamic content generation, in the code sample shouldn't
createTextNode() and appendChild be used instead of insertText (which
I don't believe is valid or was copied from code referencing custom
methods)?

This worked for me:

function fillContent() {
       // parentelem is a specified element in the DOM - OR uncomment below
       // var docelems=document.getElementsByTagName("body");
       // var parentelem=docelems.item(0);
       var htext=document.createTextNode("This is test text.");
       var header = document.createElement("h1");
       header.appendChild(htext);
       var para = document.createElement("p");
       var ptext=document.createTextNode("This is test text.");
       para.appendChild(ptext);
       var list = document.createElement("ul");
       itemone = document.createElement("li");
       itemonelink=document.createElement("a");
       itemonelink.setAttribute("href","foo.html");
       var itemonelinktext=document.createTextNode("This is test text.");
       itemone.appendChild(itemonelink);
       list.appendChild(itemone);
       itemonelink.appendChild(itemonelinktext);
       parentelem.appendChild(header);
       parentelem.appendChild(para);
       parentelem.appendChild(list);
}
Received on Saturday, 20 November 2004 01:18:53 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:47:32 GMT