Will firstchild.innerhtml will work in Firefox

I have a javascript function .I am gettting the value using getelementsById.and from that i have used the firstchild and firstchild.innerhtml.This funtion is working fine IE .But it is not working in Firefox .The following is my codevar myname = document.getElementById(name)

var mytext = myname.firstChild.id.split(“_”)

var mycontent=myname.firstChild.innerHTML

When i preview in firefox the error is showing in the split (second line )when i comment the statement it is showing in the last line

Is anything like that innerHTML or firstchild doesn’t work in firefox ?If so then how can i check in firefox

Does anyone has any idea

Thanks in advance

paula j

Subject: Will firstchild.innerhtml will work in Firefox

Hello Paula,

Where and how is name defined?

I tested your code in Firefox and it worked fine.

My content

Subject: RE: Will firstchild.innerhtml will work in Firefox

Hi,myname contains the document id

function test(unid1)

{

var myname= document.getElementById(‘S_’ + unid1)

var mytext =myname.firstChild.id.split(“_”)

var tmycontent=myname.firstChild.innerHTML

}

In IE it working fine,only in firefox iam not getting .Instead i am getting the error " myname.firstChild.id has no properties" in the javascript console

How to solve this?I dont’t knwo what mistake i have done

Subject: RE: Will firstchild.innerhtml will work in Firefox

The “first child” may be a null node in Firefox (or any Mozilla variant), depending on how the whitespace (line feeds, etc.) are arranged. For instance:

This is the first child

This may not be the first child

You should be checking the node type and moving to the next sibling while the node type is not what you want. Rich Schwartz has published a cross-browser implementation of this on his blog:

http://www.rhs.com/web/blog/poweroftheschwartz.nsf/d6plinks/RSCZ-6CJNE2

and in an article for Lotus Advisor magazine.