06-30-2009 07:04 AM
In our appln we have used the javascript
if(!hasInnerText){
elem.textContent = str;
} else{
elem.innerText = str;
}
But neither of them works i.e it doesnt displays the value content in the str
We have tested in 9500 and 9000 with both blackberry browser+IE +Mozilla simulator.
However when we replace with innerHTML it works ,so kindly pls help me with this ASAP...
Thanks
06-30-2009 08:31 AM
The textContent property is a DOM L3 construct and isn't supported in older versions of the code. I don't know where you got innerText from, I've never seen that in any spec.
You can try something like the following:
if (!hasInnerText) {
while (elem.firstChild) elem.removeChild( elem.firstChild ); // removes all children of elem
elem.appendChild( document.createTextNode( str ) ); // appends a new text node
} else {
elem.innerText = str;
}
09-21-2009 04:28 PM
innerText is a Microsoft feature.
textContent is a DOM 3feature.
A common idiom for web page is to use one or the other.
[code]
var text = "textContent" in el ? el.textContent : el.innerText;
[/code]