Problem with innerText/textContent

S

Srinivasa

Hai, I am new to this group. But not to Javascript.
I have a problam with innerText in FireFox.
I have the code as below.
--
var inputArea = document.getElementById("rtsText");
var outputArea = document.getElementById("uniText");
outputArea.innerText = transformInput(inputArea.value);
--
I have two elements, a textarea in which user entered RTS text, and a
div tag in which the converted Unicode text will be place using
transformInput funcion.

But my problem is, innerText is working fine in IE, but not in
FireFox. So i tried to use textContent in FireFox. It is working but
the line breaks (which will get by pressing Enter key) in the input
textare will not reflect in the output div tag. Could anybody tell me
solution.
-Thanks and Regards
-Srinivasa Raju Datla
 
V

VK

the line breaks (which will get by pressing Enter key) in the input
textare will not reflect in the output div tag.

A line break in textarea is CR, NL or CR+NL characters - depending on
OS

A visual line break in HTML is <BR> tag == characters "<"+"B"+"R"+">"

Do you see a single match or a correlation between of two? I do not -
because there is not any.

This question was just asked I believe in another thread - look
around. If you want to make a HTML markup with BR tags out of text
source with physical line breaks then use regexp to replace all \n|\r|
\r\n with "<BR>" and use innerHTML - for simple cases - for insertion
over HTML parser invocation.
 
M

Martin Honnen

Srinivasa said:
I have two elements, a textarea in which user entered RTS text, and a
div tag in which the converted Unicode text will be place using
transformInput funcion.

But my problem is, innerText is working fine in IE, but not in
FireFox. So i tried to use textContent in FireFox. It is working but
the line breaks (which will get by pressing Enter key) in the input
textare will not reflect in the output div tag.

Use a pre element instead of the div element.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top