A way to do an \n or \r\n when writing value in textLine.nodeValue??

Is there a way to do an \n or \r\n or such when writing value in textLine.nodeValue??

Since innerHTML is not recommended to use anymore when dealing with nodeValues.

Thanx.
LVL 2
walkman69Asked:
Who is Participating?
 
walkman69Connect With a Mentor Author Commented:
However I found that just doing a regular carriage return in the XML-document made the text
newline as it should. However it would be nice if \r\n could work to. But I guess I can't get everything.
Or can I?... =)
0
 
cooooolioCommented:
Use <pre> in wrapping tag
for example
<span id="span_id_xxxx"><pre> \r\n  \r\n</pre></span>
0
 
walkman69Author Commented:
Cooooolio:

It sounded like it could work..

But i tried doing it this way:


	var templateDescriptionText = document.createElement('p');
	templateDescriptionText.setAttribute('class', 'templateDescriptionText');
	templateDescriptionText.setAttribute('id', 'templateDescriptionText_1');

	var newTextNodeWrapper = document.createElement('pre');	

	newTextNode = document.createTextNode('');
	templateDescriptionText.appendChild(newTextNode);	
	
	newTextNodeWrapper.appendChild(templateDescriptionText);		
	
	templateDescription.appendChild(newTextNodeWrapper);	

Open in new window




But it still generates the text \r\n in the <p>-tag..

I also tried putting the <pre></pre> inside of templateDescriptionText, and changed the id to be on the <pre> instead so that the text would be written to it's child (the newTextNode) instead of to the <p>.

Still didn't work.. It looks like the structure you suggested when i look up html-structure in Firefox firebug, have I done anything incorrectly? Would be great if you could post a brief example (javascript).



0
 
walkman69Author Commented:
Altough not fully optimized for my needs. This solution come closest to the solution I was looking for.
0
All Courses

From novice to tech pro — start learning today.