Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-10-01
4
Medium Priority
?
251 Views
Last Modified: 2012-05-12
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.
0
Comment
Question by:walkman69
  • 3
4 Comments
 

Expert Comment

by:cooooolio
ID: 36895992
Use <pre> in wrapping tag
for example
<span id="span_id_xxxx"><pre> \r\n  \r\n</pre></span>
0
 
LVL 2

Author Comment

by:walkman69
ID: 36897940
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
 
LVL 2

Accepted Solution

by:
walkman69 earned 0 total points
ID: 36898095
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
 
LVL 2

Author Closing Comment

by:walkman69
ID: 37433184
Altough not fully optimized for my needs. This solution come closest to the solution I was looking for.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question