Forum Moderators: open

Message Too Old, No Replies

getting rid of the header when printing

         

theonliest

2:11 pm on Mar 12, 2003 (gmt 0)

10+ Year Member



I have a problem that may or may not have an easy solution,
I want the pages on a site to be printable without the header included, so all top navigation, logos and graphics would basically disappear when you go to print the page and the body info would move up, the page contains deeply nested and complicated tables so sticking all the header contect inside a div with a 'visibility:hidden' on the printer style sheet probably wouldn't work too well,
maybe there's some javascript to allow you do define exactly what gets printed on any given page...

any ideas?

Hester

3:12 pm on Mar 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just stick a redundant div around each element. Eg: <div id="printer"> Then only in your print stylesheet put "#printer {display:none;}".

I'm experimenting with this myself now, and I'm having to add positioning as well, to move the remaining elements into place (since my side menu is hidden leaving a gap).

Unfortunately I am running into problems with Mozilla, and also IE6. If I add a height to the div, IE treats it as if there's only one page! The document gets cut off. While in Mozilla, it doesn't seem to recognize the left position attribute when in Print Preview, so I'm stuck there.

These problems can be dismissed if your page is small enough to fit on one page and isn't too wide.

theonliest

3:24 pm on Mar 12, 2003 (gmt 0)

10+ Year Member



well actually I just tried something similiar by defining a class;
.nopr {display:none} in the printer style sheet and using it on the offending <tr>'s, for some reason when I defined <table class="nopr"> the stuff that disappeared was still taking up space! but this other way seems to work (on IE at least, but this might do for now).

Hester

3:36 pm on Mar 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try also wrapping the table in paragraph tags and adding a class to them. Or you could replace the tables with divs. :-)

natty

3:42 pm on Mar 12, 2003 (gmt 0)

10+ Year Member



isnt it visibility (as opposed to display) that dissapears stuff without keeping the space that it used to be in..
that is what i am using..
forget this if im talking twaddle :)