Null error in IE6 with getElementById

B

Brian A

Can anyone tell me what is wrong with :-

tNode=document.getElementById("currentStructure").firstChild;
alert("tNode="+tNode);

In Firefox the alert reports: tNode=[object Text]
In IE6 the alert reports: tNode=null

If I change the code to

tNode=document.getElementById("currentStructure").childNodes[0];
alert("tNode="+tNode);

which should be exactly the same, Firefox reports as before
but IE6 reports 'undefined'.

Either way IE6 doesn't like it. So what am I doing wrong??


Remove 'no_spam_' from email address.
Skype Free Zone!!
 
R

RobG

Brian said:
Can anyone tell me what is wrong with :-

tNode=document.getElementById("currentStructure").firstChild;
alert("tNode="+tNode);

In Firefox the alert reports: tNode=[object Text]
In IE6 the alert reports: tNode=null

If I change the code to

tNode=document.getElementById("currentStructure").childNodes[0];
alert("tNode="+tNode);

which should be exactly the same, Firefox reports as before
but IE6 reports 'undefined'.

Either way IE6 doesn't like it. So what am I doing wrong??

How are we to know what to make of a DOM structure we can't see?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top