Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

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
?
245 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

721 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