Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Print selected content from Div area using javascript

Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have some content in div area. I want to take printout the selected content from div.

In my javascript, If i select 3 lines from div content, after print out, i get the 3 line content as single line. not 3 line.

Help me,
Thanks in advance
Ranch Hand
Posts: 105
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this

I hope it help your problem.
Posts: 25669
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't forget that in HTML, line-ending characters in text are treated like spaces. And two spaces together are treated like one space. This is how HTML normalizes text. So that's why your text looks like one line, because that's how HTML works.

If you want to preserve the line endings, you have two options. One is to wrap the text in a <pre> element, which causes the usual normalization rules to not be applied. You may or may not like the way that looks, though. The other option is to replace the line-ending characters by
elements, which as you know cause the text to break to the next line. Which is what you want. Make sure that those
elements are treated as HTML markup and not as text if you do that.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic