Hi,
I am trying to learn how to dynamically write HTML using the W3C DOM.
But I am having trouble with the code. It doesn't seem to be doing
what I expect it to and I am not sure why.
Let me give an example.
document.getElementsByTagName("head")[0].appendChild(document.createElement("title"));
alert(document.getElementsByTagName("title")[0].tagName);
document.getElementsByTagName("title")[0].appendChild(createTextNode("Assignment
6"));
This code produces an error ("Object expected") on the 3rd line. I am
sure that the <title> tag has been created because the second line
produces a message box with "TITLE" in it.
Any ideas what's going wrong??