Link to home
Start Free TrialLog in
Avatar of walkman69
walkman69

asked on

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.
Avatar of cooooolio
cooooolio
Flag of Russian Federation image

Use <pre> in wrapping tag
for example
<span id="span_id_xxxx"><pre> \r\n  \r\n</pre></span>
Avatar of walkman69
walkman69

ASKER

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).



ASKER CERTIFIED SOLUTION
Avatar of walkman69
walkman69

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Altough not fully optimized for my needs. This solution come closest to the solution I was looking for.