Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
amsiddh
Posts: 142
Registered: ‎06-26-2009
My Device: Not Specified

is BB browser (IE n Mozilla) supports the javascript element.innerText and element.innerContent

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

Please use plain text.
Developer
Posts: 107
Registered: ‎09-25-2008
My Device: Not Specified

Re: is BB browser (IE n Mozilla) supports the javascript element.innerText and element.innerContent

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;
}
Please use plain text.
New Developer
Galaxy
Posts: 5
Registered: ‎09-17-2009
My Device: Not Specified

Re: is BB browser (IE n Mozilla) supports the javascript element.innerText and element.innerContent

  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]
Please use plain text.