For the most part I do know how to use these two functions as I have used them before. The problem is that when I point to the body tag it creates errors. I am using Windows XP Home edition and this bit of script produces errors on MSIE 6.0 and the script is completely ignored on Firefox 1.5 and Opera 8.51. I prefer to point to the body tag because it is the easiest and most convenient place to navigate through the DOM tree especially since the elements that I intend to create will become the first child of my body tag.
The error I get when using getElementById on MSIE is "Error: docBody is null or not an object." The error I get when using getElementsByTagName on MSIE is "Error: Object doesn't support this property or method."
The ultimate goal of my script is to create the following HTML as a first child of the body tag. However for now I will happily settle on why I am getting errors.
<DIV class="topanchor"><A name="top" class="ghost">top</A></DIV>
The complete HTML is:
<TITLE>Request For Help - PageBuilder</TITLE>
// var docBody = document.getElementById('pc');
var docBody = document.getElementsByTagName('body');
firstDiv = docBody.appendChild(document.createElement('DIV'));
firstDiv.className = 'topanchor';
topAnchor = firstDiv.appendChild(document.createElement('A'));
topAnchor.className = 'ghost';
topAnchor.name = 'top';
I really do appreciate help offered as this is evident in the countless hours that I have spent in instant messaging helping others with Windows anamolies which is something that I am very knowledgable in. Please test your solution before providing one. If you cannot provide an adequate answer to my query please do not respond to this posting. Useless responses tend to make postings long, difficult to follow, and old. Thank you for your cooperation.