Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I specify more than 1 print class and print each seperatley

Status
Not open for further replies.

rambleon

Programmer
Mar 6, 2004
130
IL
I want to print only selected sections of an (html) document. can I define several print classes. What would be the command for printing just one section be.
 

Yes, it is possible to print only certain sections of a document. You can have a print-only style sheet, which excudes elements that you do not want to print (or rather, includes elements that you do want to print).

There have been many requests like this, so I'd start by searching this forum, as well as reading through the FAQ and posts.

There is no "command" to print just one section, as such. The browser will print whatever you have told it to print in your print CSS.

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
What I meant was that if there are several sections in a document would it be possible to print different sections - <divs> - according to which command or link was pressed.
 
Yes, although you might have to use JavaScript for this one (see forum216).

One way to do this would be to have a print style sheet with a class of, say, "noprint" that sets the "display" style property to "none".

Then, using JavaScript, you could add that class to every element you did not want printed, do the print, and only what you want to print will print.

Hope this helps,
Dan

[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
I used a javascript method to do something similar on a site I did a while back.

(table layout! gasp!)
You may have to go in past the first page.

There is a "print" button at the bottom of each article etc. This prints only the content of a particular div (i.e. the article). From memory it sticks the content of said div into a different window and opens the browser's print dialogue box.

Nowadays to do the same thing I would use CSS. But you may find that you can adapt the script so you can have multiple buttons on a page to print different bits.

Foamcow Heavy Industries - Web design and ranting
Toccoa Games - Day of Defeat gaming community
Target Marketing Communications - Advertising, Direct Marketing and Public Relations
"I'm making time
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top