Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

innerText Help

Status
Not open for further replies.

TurboSRT4

Programmer
Nov 23, 2009
47
US
hello, i just did a ton of work using innerText to find out that firefox does not support it and returns undefined. Is there a way to detect browser type and if it is firefox then use innerHtml? I would appreciate help using innerHtml and simply removing all tags from the value. Thank you
 
A cross-browser replacement for ".innerText" is ".firstChild.nodeValue".

Your mileage may vary when it comes to whitespace nodes... but you could iterate through the childNodes collection until you find the appropriate node (or nodeType or whatever you find easiest to search on).

Hope this helps,

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Hi

Actually, you should use [tt]textContent[/tt] because that is the standard way, and if it is undefined, use Explorer's own [tt]innerText[/tt].

We had a similar discussion in thread216-1580940, thread surprisingly also started by you.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top