Welcome to WebmasterWorld Guest from 54.205.106.138

Forum Moderators: not2easy

Message Too Old, No Replies

print all text in a textarea

including text below the scrollbar

     
3:50 am on Oct 3, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 21, 2002
posts:977
votes: 0


I want to print a textarea with all the text in it... including the text that has scrolled off the bottom of the area. By default, browsers just truncate the text at the end of the visible area and don't print any text that you'd need to scroll to see. Is there a CSS trick to this?
4:03 am on Oct 3, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Feb 28, 2005
posts: 646
votes: 0


I've already tried this - using combinations of methods for setting 100% height, or visible overflow, minimum height, that sort of thing.

I couldn't get anything to work.

So I'm also interested to see if someone found a solution that's cross-browser compatible, or there isn't one.

5:23 am on Oct 3, 2006 (gmt 0)

New User

10+ Year Member

joined:Oct 3, 2006
posts:5
votes: 0


Is it necessary to have the text in a textarea input element? If you're just displaying something like a TOS in a scrollable box, why don't you try this instead of a textarea:

<div style="width:500px;height:500px;overflow:auto;border:1px #000 solid;">
All the text here...
</div>

It'll look almost like your textarea, but it can easily print by changing the CSS. I've used inline styles, but you'd want to use an external stylesheet.

12:17 am on Oct 4, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 21, 2002
posts:977
votes: 0


Nice idea foobar. Unfortunately it is necessary to have a textarea form element, because it is a data input form with a couple of fields which take a large amount of text with line breaks (e.g. a project description).
12:54 am on Oct 4, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2006
posts: 3123
votes: 0


If you can't print the entire <textarea> directly then, using JavaScript, you might be able to copy it's contents into a DIV (perhaps in another window) and print that. Kind of how foobar suggested. To preserve line-breaks, you could try using
white-space:pre-wrap;
(although not very well supported!) or manually replace every new-line with a <br> ...?