HCL Notes 11 - Javascript - context.text not working in firefox but works in IE

73 Views Asked by At

The below code works in IE but not in other browsers.

var node = xmlHttp.responseXML.documentElement;
var eitems = node.getElementsByTagName("nib:ProcessRequestResponse");
txt = eitems.context.text;
txt2 = txt.replace("\n", "");

Gives error "eitems.context is undefined". I have also tried eitems.context.textContent, eitems.context.innertext, eitems.context.innerHTML. All gives same error.

2

There are 2 best solutions below

1
Keertika On BEST ANSWER

I used txt = node.textContent to get the content of tag and it worked

4
Knut Herrmann On

getElementsByTagName() returns a HTMLCollection. Access the first element with

 var item = eitems.item(0);

or just

 var item = eitems[0];

Use item to get the content.