Click to See Complete Forum and Search --> : Is document.getElementById('b').innerText supported in Mozilla??


mini_dumbo
12-05-2002, 04:26 PM
We have a page running on IE that will display a specific variable in each of the table cells we have, but when we tried to run it on Mozilla, it doesn't work..... each cell is blank...... is "innerText" not supported in Mozilla?? Does anyone know what we can do??

here's what we did:

function displayLink()
{
document.getElementById('link1').innerText = newArray[x1].name ;
document.getElementById('link2').innerText = newArray[x2].name ;
:
:
etc
}

Any suggestiong appreciated!! :thumbsup:


Bo & Vic:rolleyes:

gil davis
12-05-2002, 05:32 PM
innerText is *also* IE proprietary.

The W3C DOM specification uses a thing called a "textNode". This is supported by IE 5+, NS 6+ and Mozilla:


var old = document.getElementById('link1').firstChild;
var txt = document.createTextNode(newArray[x1].name);
document.getElementById('link1').replaceChild(txt, old);

NS 6+ supports "innerHTML", which has been suggested as an addition to the W3C DOM. It can be used in place of "innerText" in most instances.

Something that you might like to look at is http://www.dannyg.com/ref/jsquickref.html. It tells you all the properties/objects/methods available for IE (up to 5.5) and NS (up to 6) versions. It has been a great help to me.

mini_dumbo
12-05-2002, 07:34 PM
thank you, the site u gave me turns out to be very useful indeed...:p

Rick Bull
12-06-2002, 04:53 AM
Opera 7 now supports innerHTML by the way, not sure about innerText though.

chatterjee_yash
05-07-2008, 04:30 AM
You can use textContent in mozilla which is equivalent to innerText in IE...


Regards,

Austin.

Teufel
05-07-2008, 05:59 AM
You can use innerHTML if it's only text or you want to add HTML, textContent is the best solution. nodeValue also works.