Javascript: innerText not working in FireFox and Safari

Posted: September 1, 2008 in Javascript
Tags: ,

Today, I came to know that innerText property of any web control is not supported by FireFox and Safari browser. Here, I found the alternate solution for innerText property.

Use the following code in javascript to acquire the same functionality as innerText.
var myText = document.getElementById(’divText’).textContent; // same as innertext.

Advertisements
Comments
  1. Ajay says:

    Thanks for the tip!!!! Works like charm..

  2. Umer says:

    Thanks for the tip its work perfectly.

  3. Caole says:

    I got a problem with this property. If my text has control characters (\n, \t,…), those will be replaced by “” if I use textContent in FF. Please help.

  4. Ramavtar Rajput says:

    Thanks for help

  5. Misha says:

    textContent working SUXX! It often include javascript code instead of text

  6. Joe says:

    thanks for find this out. It helped me a lot

  7. Oleg says:

    Just use innerHTML instead of innerText – it works in FF, Safari, Chrome etc. And your (not “\n”) will work in there.

  8. Oleg says:

    Tag removed by wordpress. 😦 There was text “And your (not “\n”) will work in there.”

  9. Temaotheree says:

    Образцовый блог, делюсь с Вами, наслаждайтесь, изучайте, зарабатывайте, http://ochupella.ru/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s